deleted function of memory of the 'box_lib.obj' now they are connected through 'lib_init'

all programs that use 'tree_list' and 't_edit' must use 'lib_init'

git-svn-id: svn://kolibrios.org@1489 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA 2010-06-09 20:06:03 +00:00
parent 4c444c11c9
commit 433be1188e
10 changed files with 109 additions and 142 deletions

View File

@ -21,47 +21,10 @@ include 'bl_sys.mac'
include 'box_lib.mac' ;macro which should make life easier :)
;-----------------------------------------------------------------------------
;ôóíêöèÿ äëÿ âûäåëåíèÿ ïàìÿòè
;input:
; ecx = size data
;otput:
; eax = pointer to memory
align 4
mem_Alloc:
push ebx
mov eax,68
mov ebx,12
int 0x40
pop ebx
ret
;ôóíêöèÿ äëÿ îñâîáîæäåíèÿ ïàìÿòè
;input:
; ecx = pointer to memory
align 4
proc mem_Free, mptr:dword
push eax ebx ecx
mov ecx,[mptr]
cmp ecx,0
jz @f
mov eax,68
mov ebx,13
int 0x40
@@:
pop ecx ebx eax
ret
endp
;ôóíêöèÿ äëÿ ïåðåðàñïðåäåëåíèÿ ïàìÿòè
;otput:
; eax = pointer to memory
align 4
proc mem_ReAlloc, mptr:dword, size:dword
push ebx ecx edx
mov edx, [mptr]
mov ecx, [size]
mcall 68, 20
pop edx ecx ebx
ret
endp
mem.alloc dd ? ;функция для выделения памяти
mem.free dd ? ;функция для освобождения памяти
mem.realloc dd ? ;функция для перераспределения памяти
dll.load dd ?
;----------------------------------------------------
;EditBox
@ -138,8 +101,17 @@ use_path_show
align 16
use_text_edit
;input:
; eax = указатель на функцию выделения памяти
; ebx = ... освобождения памяти
; ecx = ... перераспределения памяти
; edx = ... загрузки библиотеки (пока не используется)
align 16
init:
lib_init:
mov [mem.alloc], eax
mov [mem.free], ebx
mov [mem.realloc], ecx
mov [dll.load], edx
ret
@ -147,7 +119,7 @@ align 16
EXPORTS:
dd sz_init, init
dd sz_init, lib_init
dd sz_version, 0x00000001
dd sz_edit_box, edit_box

View File

@ -1,6 +1,6 @@
; ¬ ªà®á ¤«ï á¨á⥬­®© ¡¨¡«¨®â¥ª¨ box_lib.obj
; í«¥¬¥­â TextEditor ¤«ï Kolibri OS
; ä ©« ¯®á«¥¤­¨© à § ¨§¬¥­ï«áï 17.05.2010 IgorA
; ä ©« ¯®á«¥¤­¨© à § ¨§¬¥­ï«áï 09.06.2010 IgorA
; ­  ª®¤ ¯à¨¬¥­¥­  GPL2 «¨æ¥­§¨ï
;input:
@ -154,7 +154,7 @@ proc ted_init, edit:dword
mov ecx,sizeof.symbol
imul ecx,ted_max_chars
call mem_Alloc ;¢ë¤¥«ï¥¬ ¯ ¬ïâì
invoke mem.alloc,ecx ;¢ë¤¥«ï¥¬ ¯ ¬ïâì
mov ted_tex,eax
mov ted_tex_1,eax
add ted_tex_1,sizeof.symbol
@ -166,7 +166,7 @@ proc ted_init, edit:dword
;-------------------------------------------------
mov ecx,1024 ;1024 - ¤«ï ¬ áᨢ  ted_arr_key_pos
add ecx,ted_syntax_file_size
call mem_Alloc
invoke mem.alloc,ecx
mov ted_arr_key_pos,eax
add eax,1024
mov ted_syntax_file,eax
@ -255,8 +255,8 @@ align 4
proc ted_delete, edit:dword
push edi
mov edi,dword[edit]
stdcall mem_Free,ted_tex
stdcall mem_Free,ted_arr_key_pos ;ted_syntax_file
invoke mem.free,ted_tex
invoke mem.free,ted_arr_key_pos ;ted_syntax_file
pop edi
ret
endp
@ -1204,7 +1204,7 @@ proc ted_memory_increase
add ecx,ted_max_chars
mov ted_max_chars,ecx
imul ecx,sizeof.symbol
stdcall mem_ReAlloc, ted_tex,ecx
invoke mem.realloc, ted_tex,ecx
mov ebx,ted_tex
mov ted_tex,eax
mov ted_tex_1,eax
@ -3946,7 +3946,7 @@ proc ted_but_save_file, edit:dword, file:dword, f_name:dword
je .no_save
mov ecx,ted_max_chars
call mem_Alloc
invoke mem.alloc,ecx
push eax ;§ ¯®¬¨­ ¥¬ 㪠§ â¥«ì ­  ¢ë¤¥«¥­­ãî ¯ ¬ïâì
mov edx,ted_tex
@ -3999,7 +3999,7 @@ call ted_fun_save_err
@@:
pop ecx ;§ ¯¨á뢠¥¬ 㪠§ â¥«ì ­  ¢ë¤¥«¥­­ãî ¯ ¬ïâì
stdcall mem_Free,ecx
invoke mem.free,ecx
.no_save:
popad
ret

View File

@ -1,6 +1,6 @@
; макрос для системной библиотеки box_lib.obj
; элемент TreeList для Kolibri OS
; ôàéë ïîñëåäíèé ðàç èçìåíÿëñÿ 15.05.2010 IgorA
; ôàéë ïîñëåäíèé ðàç èçìåíÿëñÿ 09.06.2010 IgorA
; на код применена GPL2 лицензия
@ -27,14 +27,14 @@ tl_data_init: ;
xor ecx,ecx
mov cx,tl_info_size
imul ecx,tl_info_max_count
call mem_Alloc
invoke mem.alloc,ecx
mov dword[edi],eax ;копируем указатель на полученую память в структуру
mov tl_data_img,0 ;обнуляем указатель 'data_img'
mov tl_data_img_sys,0 ;обнуляем указатель 'data_img_sys'
mov ecx,sizeof.TreeList
imul ecx,tl_info_max_count
call mem_Alloc
invoke mem.alloc,ecx
mov tl_data_nodes,eax ;копируем указатель на полученую память в структуру
push dword edi
@ -70,15 +70,15 @@ proc tl_data_clear, tlist:dword ;
mov edi,dword[tlist]
cmp tl_data_img,0
je @f
stdcall mem_Free,tl_data_img ;÷èñòêà ñèñòåìíûõ èêîíîê
invoke mem.free,tl_data_img ;÷èñòêà ñèñòåìíûõ èêîíîê
@@:
cmp tl_data_img_sys,0
je @f
stdcall mem_Free,tl_data_img_sys ;÷èñòêà ñèñòåìíûõ èêîíîê
invoke mem.free,tl_data_img_sys ;÷èñòêà ñèñòåìíûõ èêîíîê
@@:
stdcall mem_Free,dword[edi]
invoke mem.free,dword[edi]
stdcall mem_Free,tl_data_nodes
invoke mem.free,tl_data_nodes
pop edi
ret
endp

View File

@ -1,5 +1,7 @@
align 4
boxlib_import:
dd alib_init2 ;функция запускается макросом 1 раз при подключении бибилиотеки, потому в программе метка на нее не нужна
edit_box_draw dd aEdit_box_draw
edit_box_key dd aEdit_box_key
edit_box_mouse dd aEdit_box_mouse
@ -44,6 +46,7 @@ boxlib_import:
tl_get_mem_size dd sz_tl_get_mem_size
dd 0,0
alib_init2 db 'lib_init',0
aEdit_box_draw db 'edit_box',0
aEdit_box_key db 'edit_box_key',0
@ -90,7 +93,7 @@ boxlib_import:
align 4
libini_import:
lib_init_ini dd alib_init0
dd alib_init0
ini_get_str dd aini_get_str
dd 0,0
alib_init0 db 'lib_init',0
@ -98,7 +101,7 @@ dd 0,0
align 4
libimg_import:
lib_init dd alib_init1
dd alib_init1
img_is_img dd aimg_is_img
img_info dd aimg_info
img_from_file dd aimg_from_file

View File

@ -0,0 +1,48 @@
;-----------------------------------------------------------------------------
proc mem.Alloc,size ;/////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
push ebx ecx
mov ecx,[size]
;*** add ecx,4
mcall 68,12
;*** add ecx,-4
;*** mov [eax],ecx
;*** add eax,4
pop ecx ebx
ret
endp
;-----------------------------------------------------------------------------
proc mem.ReAlloc,mptr,size ;//////////////////////////////////////////////////
;-----------------------------------------------------------------------------
push ebx ecx edx
mov ecx,[size]
or ecx,ecx
jz @f
;*** add ecx,4
@@: mov edx,[mptr]
or edx,edx
jz @f
;*** add edx,-4
@@: mcall 68,20
or eax,eax
jz @f
;*** add ecx,-4
;*** mov [eax],ecx
;*** add eax,4
@@: pop edx ecx ebx
ret
endp
;-----------------------------------------------------------------------------
proc mem.Free,mptr ;//////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
push ebx ecx
mov ecx,[mptr]
or ecx,ecx
jz @f
;*** add ecx,-4
@@: mcall 68,13
pop ecx ebx
ret
endp

View File

@ -26,7 +26,7 @@ struct symbol
ends
hed db 'TextEditor 27.05.10',0 ;¯®¤¯¨áì ®ª­ 
hed db 'TextEditor 09.06.10',0 ;¯®¤¯¨áì ®ª­ 
sc system_colors
fn_icon db 'te_icon.bmp',0
@ -43,37 +43,6 @@ ted_on_init_synt_err:
ret
;-----------------------------------------------------------------------------
;äã­ªæ¨ï ¤«ï ¢ë¤¥«¥­¨ï ¯ ¬ïâ¨
;input:
; ecx = size data
;otput:
; eax = pointer to memory
align 4
mem_Alloc:
push ebx
mov eax,68
mov ebx,12
int 0x40
pop ebx
ret
;-----------------------------------------------------------------------------
;äã­ªæ¨ï ¤«ï ®á¢®¡®¦¤¥­¨ï ¯ ¬ïâ¨
;input:
; ecx = pointer to memory
align 4
mem_Free:
push eax ebx
cmp ecx,0
jz @f
mov eax,68
mov ebx,13
int 0x40
@@:
pop ebx eax
ret
align 4
ted_but_new_file:
push eax ebx

View File

@ -13,7 +13,9 @@ fn_icon_tl_nod db 'tl_nod_16.bmp',0
;---------------------------------------------------------------------
align 4
myimport:
boxlib_import:
dd alib_init2 ;функция запускается макросом 1 раз при подключении бибилиотеки, потому в программе метка на нее не нужна
edit_box_draw dd aEdit_box_draw
edit_box_key dd aEdit_box_key
edit_box_mouse dd aEdit_box_mouse
@ -87,6 +89,7 @@ myimport:
;version_text_edit dd sz_ted_version
dd 0,0
alib_init2 db 'lib_init',0
aEdit_box_draw db 'edit_box',0
aEdit_box_key db 'edit_box_key',0

View File

@ -21,9 +21,9 @@ maxSyntaxFileSize equ 410000
include '../../proc32.inc'
include '../../macros.inc'
include 'mem.inc'
include '../../develop/libraries/box_lib/load_lib.mac'
include '../../develop/libraries/box_lib/trunk/box_lib.mac'
include 'lang.inc'
include '../../develop/libraries/box_lib/asm/trunk/opendial.mac'
use_OpenDialog
@ -33,7 +33,7 @@ include 'strlen.inc'
include 't_draw.inc' ;draw main window functions
include 't_button.inc' ;text work functions
@use_library
@use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,0
align 4
start:
@ -76,7 +76,7 @@ init_OpenDialog OpenDialog_data
; init bmp file
mov ecx,1200*18
call mem_Alloc
stdcall mem.Alloc,ecx
mov [bmp_icon],eax
copy_path fn_icon,sys_path,file_name,0x0
@ -103,7 +103,7 @@ init_OpenDialog OpenDialog_data
copy_path fn_icon_tl_sys,sys_path,file_name,0x0
mov ecx,3*256*13
call mem_Alloc
stdcall mem.Alloc,ecx
mov dword[tree1.data_img_sys],eax
;mov [run_file_70.Function], 0
@ -126,7 +126,7 @@ init_OpenDialog OpenDialog_data
copy_path fn_icon_tl_nod,sys_path,file_name,0x0
mov ecx,3*256*2
call mem_Alloc
stdcall mem.Alloc,ecx
mov dword[tree1.data_img],eax
; mov [run_file_70.Function], 0
@ -494,8 +494,7 @@ button:
stdcall [mb_create],msgbox_8,thread ;message: save changes in file?
jmp still
@@:
mov ecx,[bmp_icon]
call mem_Free
stdcall mem.Free,[bmp_icon]
stdcall [ted_delete], tedit0
stdcall dword[tl_data_clear], tree1
@ -531,7 +530,7 @@ end if
;library structures
l_libs_start:
lib0 l_libs boxlib_name, sys_path, file_name, system_dir0, err_message_found_lib0, head_f_l0, myimport,err_message_import0, head_f_i0
lib0 l_libs boxlib_name, sys_path, file_name, system_dir0, err_message_found_lib0, head_f_l0, boxlib_import,err_message_import0, head_f_i0
lib1 l_libs msgbox_name, sys_path, file_name, system_dir1, err_message_found_lib1, head_f_l0, msgbox_lib_import, err_message_import1, head_f_i0
load_lib_end:

View File

@ -10,7 +10,9 @@ fn_icon_tl_nod db 'tl_nod_16.bmp',0
;---------------------------------------------------------------------
align 4
myimport:
boxlib_import:
dd alib_init2 ;функция запускается макросом 1 раз при подключении бибилиотеки, потому в программе метка на нее не нужна
edit_box_draw dd aEdit_box_draw
edit_box_key dd aEdit_box_key
edit_box_mouse dd aEdit_box_mouse
@ -83,6 +85,7 @@ ted_text_colored dd sz_ted_text_colored
;version_text_edit dd sz_ted_version
dd 0,0
alib_init2 db 'lib_init',0
aEdit_box_draw db 'edit_box',0
aEdit_box_key db 'edit_box_key',0

View File

@ -17,11 +17,11 @@ include '../../macros.inc'
include '../../proc32.inc'
include '../../develop/libraries/box_lib/load_lib.mac'
include '../../develop/libraries/box_lib/trunk/box_lib.mac'
include '../t_edit/mem.inc'
include 'te_data.inc'
include 'te_work.inc' ;text work functions
@use_library
@use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,0
align 4
start:
@ -39,7 +39,7 @@ start:
;-------------------------------------------------
mov ecx,maxSyntaxFileSize
call mem_Alloc
stdcall mem.Alloc,ecx
mov [options_file],eax
mov [options_file_end],eax
add [options_file_end],ecx
@ -59,13 +59,13 @@ load_libraries l_libs_start,load_lib_end
copy_path fn_icon_tl_sys,sys_path,file_name,0
mov ecx,3*256*13
call mem_Alloc
stdcall mem.Alloc,ecx
mov dword[tree1.data_img_sys],eax
mov [run_file_70.Function], 0
mov [run_file_70.Position], 54
mov [run_file_70.Flags], 0
mov [run_file_70.Count], 3*256*13
mov [run_file_70.Count], ecx
mov [run_file_70.Buffer], eax
mov byte[run_file_70+20], 0
mov [run_file_70.FileName], file_name
@ -82,13 +82,13 @@ load_libraries l_libs_start,load_lib_end
copy_path fn_icon_tl_nod,sys_path,file_name,0
mov ecx,3*256*2
call mem_Alloc
stdcall mem.Alloc,ecx
mov dword[tree1.data_img],eax
; mov [run_file_70.Function], 0
; mov [run_file_70.Position], 54
; mov [run_file_70.Flags], 0
mov [run_file_70.Count], 3*256*2
mov [run_file_70.Count], ecx
mov [run_file_70.Buffer], eax
; mov byte[run_file_70+20], 0
; mov [run_file_70.FileName], file_name
@ -244,8 +244,7 @@ button:
.exit:
;push eax
mov ecx,[options_file]
call mem_Free
stdcall mem.Free,[options_file]
stdcall [tl_data_clear], tree1
stdcall [ted_delete], tedit0
@ -301,7 +300,7 @@ get_wnd_in_focus:
;@@:
ret
hed db 'TextEditor syntax file converter 31.05.10',0 ;¯®¤¯¨áì ®ª­ 
hed db 'TextEditor syntax file converter 09.06.10',0 ;¯®¤¯¨áì ®ª­ 
txtErrOpen db '<27>¥ ­ ©¤¥­ ä ©«, ¯à®¢¥àì⥠¯à ¢¨«ì­®áâì ¨¬¥­¨',0
txtErrIni0 db '<27>¥ ®âªàë«áï ä ©« á ¨ª®­ª ¬¨',0
@ -325,38 +324,9 @@ err_message_found_lib1 db 'Sorry I cannot found library msgbox.obj',0
;library structures
l_libs_start:
lib0 l_libs boxlib_name, sys_path, file_name, system_dir0, err_message_found_lib0, head_f_l0, myimport,err_message_import0, head_f_i0
lib0 l_libs boxlib_name, sys_path, file_name, system_dir0, err_message_found_lib0, head_f_l0, boxlib_import,err_message_import0, head_f_i0
load_lib_end:
;-----------------------------------------------------------------------------
;äã­ªæ¨ï ¤«ï ¢ë¤¥«¥­¨ï ¯ ¬ïâ¨
;input:
; ecx = size data
;otput:
; eax = pointer to memory
align 4
mem_Alloc:
push ebx
mov eax,68
mov ebx,12
int 0x40
pop ebx
ret
;-----------------------------------------------------------------------------
;äã­ªæ¨ï ¤«ï ®á¢®¡®¦¤¥­¨ï ¯ ¬ïâ¨
;input:
; ecx = pointer to memory
align 4
mem_Free:
push eax ebx
cmp ecx,0
jz @f
mov eax,68
mov ebx,13
int 0x40
@@:
pop ebx eax
ret
i_end:
rb 1024