News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Alloc Function causing crashes

Started by Farabi, February 20, 2012, 08:57:43 AM

Previous topic - Next topic

Farabi

Alloc funciton is limited to less than 1000 handle. I tried to allocating 87142 handle and it is crashed, it seems to be the handle table used is minimum, changing it to globalalloc and everything went fine again.

I'd suggest this for replacement

mAlloc proc nSize:dword

add nSize,4
invoke GlobalAlloc,GMEM_ZEROINIT or GMEM_FIXED,nSize
.if eax==0
invoke MessageBox,NULL,CADD("Unable to allocate memory"),NULL,MB_OK
.endif

ret
mAlloc endp
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

dedndave

QuoteI tried to allocating 87142 handle and it is crashed

:eek

i am surprised you got to 87141   :lol

allocate fewer large blocks, then split them up with pointers

MichaelW

I doubt that many people use the Alloc procedure. A more reasonable choice is to use the alloc macro (which calls GlobalAlloc with GMEM_ZEROINIT or GMEM_FIXED), and check the returned pointer.
eschew obfuscation