replace old kernel_free with mem_free

git-svn-id: svn://kolibrios.org@887 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2008-10-27 23:38:33 +00:00
parent bc6cebbf4b
commit 3f22b06b9f
14 changed files with 296 additions and 309 deletions

View File

@ -558,7 +558,7 @@ endp
; ebx= size of file
;
; warging
; You mast call kernel_free() to delete each file
; You mast call mem_free() to delete each file
; loaded by the load_file() function
align 4
@ -636,7 +636,8 @@ proc load_file stdcall, file_name:dword
pop esi
ret
.cleanup:
stdcall kernel_free, [file]
mov ecx, [file]
call @mem_free@4
.fail:
xor eax, eax
xor ebx, ebx
@ -826,12 +827,10 @@ proc load_driver stdcall, driver_name:dword
mov dword [edi], '.obj'
mov byte [edi+4], 0
stdcall load_file, edx
mov [coff], eax
test eax, eax
jz .exit
mov [coff], eax
movzx ebx, [eax+CFH.nSections]
lea edx, [eax+20]
xor ecx, ecx
@ -847,6 +846,7 @@ proc load_driver stdcall, driver_name:dword
mov edx, PG_SW
call @mem_alloc@8
test eax, eax
mov [img_base], eax
jz .fail
mov [img_base], eax
@ -923,14 +923,16 @@ proc load_driver stdcall, driver_name:dword
stdcall get_coff_sym,[sym],[ebx+CFH.nSymbols],szSTART
mov [start], eax
stdcall kernel_free, [coff]
mov ecx, [coff]
call @mem_free@4
mov ebx, [start]
stdcall ebx, DRV_ENTRY
test eax, eax
jnz .ok
stdcall kernel_free, [img_base]
mov ecx, [img_base]
call @mem_free@4
xor eax, eax
ret
.ok:
@ -961,9 +963,11 @@ proc load_driver stdcall, driver_name:dword
mov esi, msg_CR
call sys_msg_board_str
.cleanup:
stdcall kernel_free,[img_base]
mov ecx, [img_base]
call @mem_free@4
.fail:
stdcall kernel_free, [coff]
mov ecx, [coff]
call @mem_free@4
.exit:
xor eax, eax
ret
@ -1065,7 +1069,9 @@ proc load_library stdcall, file_name:dword
stdcall get_coff_sym,[sym],[ebx+CFH.nSymbols],szEXPORTS
mov [exports], eax
stdcall kernel_free, [coff]
mov ecx, [coff]
call @mem_free@4
mov eax, [exports]
ret
.fail:

View File

@ -41,8 +41,8 @@ iglobal
szAllocKernelSpace db 'AllocKernelSpace',0
szFreeKernelSpace db 'FreeKernelSpace',0
szHeapAlloc db 'HeapAlloc',0
szKernelFree db 'KernelFree',0
szMemAlloc db 'MemAlloc',0
szMemFree db 'MemFree',0
szUserAlloc db 'UserAlloc',0
szUserFree db 'UserFree',0
szKmalloc db 'Kmalloc',0
@ -112,8 +112,8 @@ kernel_export:
dd szReleasePages , release_pages
dd szFreeKernelSpace , free_kernel_space ;stdcall
dd szHeapAlloc , @mem_alloc@8 ;fastcall
dd szKernelFree , kernel_free ;stdcall
dd szMemAlloc , @mem_alloc@8 ;fastcall
dd szMemFree , @mem_free@4 ;fastcall
dd szUserAlloc , user_alloc ;stdcall
dd szUserFree , user_free ;stdcall
dd szKmalloc , malloc

View File

@ -8,36 +8,12 @@
$Revision$
struc MEM_BLOCK
{ .next_block dd ?
.prev_block dd ? ;+4
.list_fd dd ? ;+8
.list_bk dd ? ;+12
.base dd ? ;+16
.size dd ? ;+20
.flags dd ? ;+24
.handle dd ? ;+28
}
MEM_LIST_OFFSET equ 8
FREE_BLOCK equ 4
USED_BLOCK equ 8
DONT_FREE_BLOCK equ 10h
virtual at 0
MEM_BLOCK MEM_BLOCK
end virtual
MEM_BLOCK_SIZE equ 8*4
block_next equ MEM_BLOCK.next_block
block_prev equ MEM_BLOCK.prev_block
list_fd equ MEM_BLOCK.list_fd
list_bk equ MEM_BLOCK.list_bk
block_base equ MEM_BLOCK.base
block_size equ MEM_BLOCK.size
block_flags equ MEM_BLOCK.flags
align 4
proc free_kernel_space stdcall uses ebx ecx edx esi edi, base:dword
@ -46,21 +22,6 @@ proc free_kernel_space stdcall uses ebx ecx edx esi edi, base:dword
endp
align 4
proc kernel_free stdcall, base:dword
ret
endp
restore block_next
restore block_prev
restore block_list
restore block_base
restore block_size
restore block_flags
;;;;;;;;;;;;;; USER ;;;;;;;;;;;;;;;;;
HEAP_TOP equ 0x5FC00000

View File

@ -38,9 +38,13 @@ proc load_PE stdcall, file_name:dword
test eax, eax
jnz .cleanup
stdcall kernel_free, [base]
mov ecx, [base]
call @mem_free@4
.cleanup:
stdcall kernel_free, [image]
mov ecx, [image]
call @mem_free@4
mov eax, [entry]
ret
.fail:
@ -284,7 +288,6 @@ __exports:
create_ring_buffer, 'CreateRingBuffer', \ ; stdcall
destroy_kernel_object, 'DestroyObject', \
free_kernel_space, 'FreeKernelSpace', \ ; stdcall
kernel_free, 'KernelFree', \ ; stdcall
malloc, 'Kmalloc', \
free, 'Kfree', \
map_io_mem, 'MapIoMem', \ ; stdcall

View File

@ -235,7 +235,8 @@ end if
call set_cr3
.err:
.err_hdr:
stdcall kernel_free,[file_base]
mov ecx, [file_base]
call @mem_free@4
.err_file:
xor eax, eax
mov [application_table_status],eax

View File

@ -72,7 +72,7 @@ v86_create:
mov edi, eax
add eax, 1000h
push eax
call get_pg_addr
sub eax, OS_BASE
or al, PG_UW
stosd
; ...and also copy system page tables
@ -143,7 +143,11 @@ v86_create:
; destroys: eax, ebx, ecx, edx (due to free)
v86_destroy:
push eax
stdcall kernel_free, [eax+V86_machine.pagedir]
mov ecx, [eax+V86_machine.pagedir]
sub ecx, OS_BASE
call @core_free@4
pop eax
jmp free

View File

@ -45,8 +45,8 @@ kernel_export \
ReleasePages,\
\
FreeKernelSpace, \
HeapAlloc,\
KernelFree,\
MemAlloc, \
MemFree, \
UserAlloc, \
UserFree, \
Kmalloc, \

View File

@ -83,7 +83,7 @@ proc START stdcall, state:dword
mov ecx, 16*512
mov edx, PG_SW
call HeapAlloc
call MemAlloc
test eax, eax
jz .out_of_mem
mov [mix_buff], eax
@ -426,7 +426,7 @@ proc CreateBuffer stdcall, format:dword, size:dword
add ecx, 128 ;resampler required
mov [eax+STREAM.in_size], ecx
mov edx, PG_SW
call HeapAlloc
call MemAlloc
mov edi, [str]
mov [edi+STREAM.in_base], eax
@ -513,9 +513,11 @@ DestroyBuffer:
mov [ecx+STREAM.str_fd], ebx
popf
stdcall KernelFree, [eax+STREAM.in_base]
mov ecx, [eax+STREAM.in_base]
call MemFree
mov eax, [.handle]
stdcall KernelFree, [eax+STREAM.out_base]
mov ecx, [eax+STREAM.out_base]
call MemFree
pop eax ;restore stack
call DestroyObject ;eax= stream

View File

@ -511,7 +511,7 @@ proc create_primary_buff
mov ecx, 0x10000
mov edx, PG_SW
call HeapAlloc
call MemAlloc
mov [ctrl.buffer], eax
mov edi, eax

View File

@ -533,7 +533,7 @@ proc create_primary_buff
mov ecx, 0x10000
mov edx, PG_SW
call HeapAlloc
call MemAlloc
mov [ctrl.buffer], eax
mov edi, eax

View File

@ -168,12 +168,12 @@ ntfs_setup: ; CODE XREF: part_set.inc
@@:
; $MFT and $MFTMirr invalid!
.fail_free_frs:
push [ntfs_data.frs_buffer]
call kernel_free
mov ecx, [ntfs_data.frs_buffer]
call @mem_free@4
jmp problem_fat_dec_count
.fail_free_mft:
push [ntfs_data.mft_retrieval]
call kernel_free
mov ecx, [ntfs_data.mft_retrieval]
call @mem_free@4
jmp .fail_free_frs
.mftok:
; read $MFT table retrieval information
@ -259,9 +259,9 @@ ntfs_setup: ; CODE XREF: part_set.inc
mov ecx, [ntfs_data.mft_retrieval_size]
add ecx, ecx
rep movsd
push [ntfs_data.mft_retrieval]
mov ecx, [ntfs_data.mft_retrieval]
mov [ntfs_data.mft_retrieval], eax
call kernel_free
call @mem_free@4
mov eax, [ntfs_data.mft_retrieval_size]
.ok:
shl eax, 3
@ -980,8 +980,8 @@ ntfs_find_lfn:
@@:
; reallocate
push eax
push [ntfs_data.cur_index_buf]
call kernel_free
mov ecx, [ntfs_data.cur_index_buf]
call @mem_free@4
pop ecx
mov [ntfs_data.cur_index_size], ecx
mov edx, PG_SW
@ -1013,10 +1013,10 @@ ntfs_find_lfn:
rep movsd
mov esi, eax
mov [ntfs_data.cur_index_size], ebp
push esi ebp
push [ntfs_data.cur_index_buf]
call kernel_free
pop ebp esi
mov ecx, [ntfs_data.cur_index_buf]
call @mem_free@4
mov [ntfs_data.cur_index_buf], esi
.ok2:
add esi, 10h
@ -1327,8 +1327,8 @@ ntfs_HdReadFolder:
@@:
; reallocate
push eax
push [ntfs_data.cur_index_buf]
call kernel_free
mov ecx, [ntfs_data.cur_index_buf]
call @mem_free@4
pop ecx
mov [ntfs_data.cur_index_size], ecx
mov edx, PG_SW
@ -1365,10 +1365,10 @@ ntfs_HdReadFolder:
rep movsd
mov esi, eax
mov [ntfs_data.cur_index_size], ebp
push esi ebp
push [ntfs_data.cur_index_buf]
call kernel_free
pop ebp esi
mov ecx, [ntfs_data.cur_index_buf]
call @mem_free@4
mov [ntfs_data.cur_index_buf], esi
.ok2:
add esi, 10h

View File

@ -27,7 +27,9 @@ read_skin_file:
mov esi, eax
mov edi, skin_data
rep movsd
stdcall kernel_free, eax
mov ecx, eax
call @mem_free@4
call parse_skin_data
xor eax, eax
@ -37,9 +39,10 @@ read_skin_file:
inc eax
ret
.noskin:
stdcall kernel_free, eax
push 2
pop eax
mov ecx, eax
call @mem_free@4
mov eax, 2
ret
struct SKIN_HEADER

View File

@ -142,6 +142,7 @@ extrn _init
extrn _init_mm
extrn @core_alloc@4
extrn @core_free@4
extrn @init_heap@8
extrn @find_large_md@4
@ -2280,7 +2281,10 @@ sys_background:
pushad
; return memory for old background
stdcall kernel_free, [img_background]
mov ecx, [img_background]
call @mem_free@4
; calculate RAW size
xor eax,eax
inc eax

View File

@ -366,8 +366,8 @@ proc load_cursor stdcall, src:dword, flags:dword
stdcall load_file, [src]
test eax, eax
jz .fail
mov [src], eax
jz .fail
@@:
push ebx
push esi
@ -383,7 +383,9 @@ proc load_cursor stdcall, src:dword, flags:dword
cmp word [flags], LOAD_FROM_FILE
jne .exit
stdcall kernel_free, [src]
mov ecx, [src]
call @mem_free@4
.exit:
pop edi
pop esi
@ -436,7 +438,8 @@ align 4
destroy_cursor:
push eax
stdcall kernel_free, [eax+CURSOR.base]
mov ecx, [eax+CURSOR.base]
call @mem_free@4
pop eax
call destroy_kernel_object