News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

How do I use the C function "free" to deallocate memory in masm?

Started by assembler, February 13, 2017, 01:26:12 AM

Previous topic - Next topic

LordAdef



These are the two macros used together in MASM32.

      alloc MACRO bytecount
        invoke GlobalAlloc,GMEM_FIXED or GMEM_ZEROINIT,bytecount
        EXITM <eax>
      ENDM

Hi Hutch,
Sorry to resurrect this thread, but it is one of the first to pop up in the forum´s search for "Malloc"

The reference in the masm32 help says "Malloc" instead of "Alloc". I got it right after reading your comment, but I thought it was worth pointing this out, since newbies may read this

hutch--

Alex,

Its the case sensitive different, alloc() is a macro that uses GlobalAlloc() where Malloc is a very old module written by Ernie Murphy. I would stay away from the old modules, they are left there for backwards compatibility.

Use "alloc()" and "free" as they are safe and well behaved.

LordAdef



Its the case sensitive different, alloc() is a macro that uses GlobalAlloc() where Malloc is a very old module written by Ernie Murphy. I would stay away from the old modules, they are left there for backwards compatibility.

Thanks Hutch. I´m already using it. It´s just that I coudn´t find alloc() in the masm32 help, although malloc is there

jj2007