fix Alloc function, clean code

git-svn-id: svn://kolibrios.org@8196 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA 2020-11-14 19:00:55 +00:00
parent 25cf1adde0
commit 8b59b0bc76
4 changed files with 21 additions and 53 deletions

View File

@ -101,19 +101,11 @@ end if
movsd movsd
Kolibri_Put_MovEaxVal_Ret @Kolibri@GetPid$qv,edx Kolibri_Put_MovEaxVal_Ret @Kolibri@GetPid$qv,edx
if defined KolibriHeapInit if defined KolibriHeapInit
mov ecx,esp call KolibriHeapInit ; Initialize a dynamic heap
push ebx end if
push ecx
push U_END
call KolibriHeapInit ; Initialize a dynamic heap and create new memory in its begin.
pop ecx ; Parameters: begin of a new heap, end of data to create in
mov [esp+4],eax ; the begin of a heap. Return address of the created data.
mov dword [esp],0
else
xor eax,eax xor eax,eax
push eax push eax
push eax push eax
end if
call @Kolibri@ThreadMain$qpvt1 call @Kolibri@ThreadMain$qpvt1
.ThreadFinish: .ThreadFinish:
add esp,8 add esp,8

View File

@ -2,31 +2,15 @@
#define __KOLIBRI_HEAP_H_INCLUDED_ #define __KOLIBRI_HEAP_H_INCLUDED_
#include "kolibri.h" #include "kolibri.h"
#include "memheap.h"
// Kolibri memory heap interface. // Kolibri memory heap interface.
namespace Kolibri // All kolibri functions, types and data are nested in the (Kolibri) namespace. namespace Kolibri // All kolibri functions, types and data are nested in the (Kolibri) namespace.
{ {
long _HeapInit() long HeapInit();
{ void *Alloc(unsigned long int size);
return MemoryHeap::mem_Init(); void *ReAlloc(void *mem, unsigned long int size);
} void Free(void *mem);
void *Alloc(unsigned int size)
{
return MemoryHeap::mem_Alloc(size);
}
void *ReAlloc(void *mem, unsigned int size)
{
return MemoryHeap::mem_ReAlloc(size, mem);
}
void Free(void *mem)
{
MemoryHeap::mem_Free(mem);
}
} }
#endif // ndef __KOLIBRI_HEAP_H_INCLUDED_ #endif // ndef __KOLIBRI_HEAP_H_INCLUDED_

View File

@ -1,37 +1,42 @@
;/*** ;/***
KolibriHeapInit = @@Kolibri@_HeapInit$qv KolibriHeapInit = @Kolibri@HeapInit$qv
KolibriHeapAlloc = @@Kolibri@Alloc$qui KolibriHeapAlloc = @Kolibri@Alloc$qul
KolibriHeapReAlloc = @@Kolibri@ReAlloc$qpvui KolibriHeapReAlloc = @Kolibri@ReAlloc$qpvul
KolibriHeapFree = @@Kolibri@Free$qpv KolibriHeapFree = @Kolibri@Free$qpv
proc @MemoryHeap@mem_Init$qv uses ebx align 4
proc @Kolibri@HeapInit$qv uses ebx
mov eax,SF_SYS_MISC mov eax,SF_SYS_MISC
mov ebx,SSF_HEAP_INIT mov ebx,SSF_HEAP_INIT
int 0x40 int 0x40
ret ret
endp endp
proc @MemoryHeap@mem_Alloc$qul uses ebx align 4
proc @Kolibri@Alloc$qul uses ebx
mov eax,SF_SYS_MISC mov eax,SF_SYS_MISC
mov ebx,SSF_MEM_ALLOC mov ebx,SSF_MEM_ALLOC
mov ecx,[esp+8]
int 0x40 int 0x40
ret ret
endp endp
proc @MemoryHeap@mem_ReAlloc$qulpv uses ebx align 4
proc @Kolibri@ReAlloc$qpvul uses ebx
mov eax,SF_SYS_MISC mov eax,SF_SYS_MISC
mov ebx,SSF_MEM_REALLOC mov ebx,SSF_MEM_REALLOC
mov ecx,[esp+8] mov ecx,[esp+12]
mov edx,[esp+12] mov edx,[esp+8]
int 0x40 int 0x40
ret ret
endp endp
proc @MemoryHeap@mem_Free$qpv uses ebx align 4
proc @Kolibri@Free$qpv uses ebx
mov eax,SF_SYS_MISC mov eax,SF_SYS_MISC
mov ebx,SSF_MEM_FREE mov ebx,SSF_MEM_FREE
mov ecx,[esp+8] mov ecx,[esp+8]

View File

@ -1,13 +0,0 @@
#ifndef __MEMORY_HEAP_H_INCLUDED_
#define __MEMORY_HEAP_H_INCLUDED_
namespace MemoryHeap
{
long mem_Init();
void *mem_Alloc(unsigned long size);
void *mem_ReAlloc(unsigned long size, void *mem);
bool mem_Free(void *mem);
}
#endif // ndef __MEMORY_HEAP_H_INCLUDED_