Better fix to the problem, thanks diamond for pointing it out

There're some other issues revealed though, I'm looking into them

git-svn-id: svn://kolibrios.org@627 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Mihail Semenyako (mike.dld) 2007-09-15 22:17:10 +00:00
parent 5aa81d7197
commit f53429e2f8

View File

@ -587,75 +587,33 @@ proc mem.Alloc,size ;/////////////////////////////////////////////////////////
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
push ebx ecx push ebx ecx
mov ecx,[size] mov ecx,[size]
add ecx,4+4095 add ecx,4
and ecx,not 4095
mcall 68,12 mcall 68,12
add ecx,-4 add ecx,-4
mov [eax],ecx mov [eax],ecx
add eax,4 add eax,4
pop ecx ebx pop ecx ebx
ret ret
@^
push ebx ecx
mov eax,[size]
lea ecx,[eax+4+4095]
and ecx,not 4095
mcall 68,12
add ecx,-4
mov [eax],ecx
add eax,4
pop ecx ebx
ret
^@
endp endp
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
proc mem.ReAlloc,mptr,size ;////////////////////////////////////////////////// proc mem.ReAlloc,mptr,size ;//////////////////////////////////////////////////
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
@^
push ebx ecx edx push ebx ecx edx
mov ecx,[size] mov ecx,[size]
add ecx,4+4095 or ecx,ecx
and ecx,not 4095 jz @f
mov edx,[mptr] add ecx,4
@@: mov edx,[mptr]
or edx,edx
jz @f
add edx,-4 add edx,-4
mcall 68,20 @@: mcall 68,20
add ecx,-4 add ecx,-4
mov [eax],ecx mov [eax],ecx
add eax,4 add eax,4
pop edx ecx ebx pop edx ecx ebx
ret ret
^@
push ebx ecx esi edi eax
mov eax,[mptr]
mov ebx,[size]
or eax,eax
jz @f
lea ecx,[ebx+4+4095]
and ecx,not 4095
add ecx,-4
cmp ecx,[eax-4]
je .exit
@@: stdcall mem.Alloc,ebx
xchg eax,[esp]
or eax,eax
jz .exit
mov esi,eax
xchg eax,[esp]
mov edi,eax
mov ecx,[esi-4]
cmp ecx,[edi-4]
jbe @f
mov ecx,[edi-4]
@@: add ecx,3
shr ecx,2
cld
rep movsd
xchg eax,[esp]
stdcall mem.Free,eax
.exit:
pop eax edi esi ecx ebx
ret
endp endp
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
@ -663,16 +621,10 @@ proc mem.Free,mptr ;//////////////////////////////////////////////////////////
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
push ebx ecx push ebx ecx
mov ecx,[mptr] mov ecx,[mptr]
or ecx,ecx
jz @f
add ecx,-4 add ecx,-4
mcall 68,13 @@: mcall 68,13
pop ecx ebx pop ecx ebx
ret ret
@^
push ebx ecx
mov eax,[mptr]
lea ecx,[eax-4]
mcall 68,13
pop ecx ebx
ret
^@
endp endp