Using malloc directly...
BlitzMax Forums/BlitzMax Programming/Using malloc directly...
| ||
Is there a simple way to call the c version of malloc directly? I'm just playing with test apps to see if I can generate this memory access exception and was wondering if calling malloc directly as opposed to using MemAlloc would effect the results, in effect is the heap limit I'm hitting related to BlitzMax or the GCC compiler? |
| ||
local buffer:byte ptr=MemAlloc(1024) sorry.. to use direct c commands use this: SuperStrict Extern "C" Function malloc:Byte Ptr(size:Int) Function free(buffer:Byte Ptr) Function memset:Byte Ptr(dest:Byte Ptr,value:Int,size:Int) End Extern Local buffer:Byte Ptr = malloc(1024) memset(buffer , 123 , 1024) For Local i:Int = 0 Until 1024 Print buffer[i] next free(buffer) |
| ||
MemAlloc calls malloc yes, but it also aligns on 16 byte boundaries. Potentially making the pointer incompatible with free and realloc. |
| ||
That does call malloc(), but only after wrapping it aligning it and adding about 16 bytes to it (for the GC system), so it's not direct! |
| ||
^^ edited my post to use direct c commands |
| ||
Cheers just what I needed! |