The MASM Forum

Projects => MASM32 => Topic started by: bsdsource on January 13, 2014, 09:33:20 AM

Title: Malloc masm32 library problem
Post by: bsdsource on January 13, 2014, 09:33:20 AM
In the masm32 library help file, I see that there is a Malloc and a Free procedure. I attempt to use them and get the following errors:

error A2006:undefined symbol : Malloc
error A2006:undefined symbol : free

I'm not having any other issues from the masm32 library except these 2. There's also some discrepancies in the help file regarding these 2 procedures. In the help file index, iMalloc shows up in the listing but Malloc doesn't. Both iFree and Free show in the index listing for Free. If I click on Free under the index listing I get page can't be found. On the other hand if I click on iFree under the index listing the help page can be found. Can someone explain the this issue?
Title: Re: Malloc masm32 library problem
Post by: jj2007 on January 13, 2014, 09:50:26 AM
You need to add crt_ before the malloc and free:

include \masm32\include\masm32rt.inc
.code
start:
   xchg rv(crt_malloc, 1000), esi
   MsgBox 0, hex$(esi), "Just malloc'ed:", MB_OK
   invoke crt_free, esi
   exit
end start
Title: Re: Malloc masm32 library problem
Post by: bsdsource on January 13, 2014, 11:58:00 AM
I'm surprised that information is not in the masm32 lib help file. Thank you for the help.  :t
Title: Re: Malloc masm32 library problem
Post by: hutch-- on January 13, 2014, 01:14:27 PM
Thats because its a different function, the old Alloc was written long ago using COM technology and the guy who wrote it has not been around for years. You can use any of a number of techniques, Windows API functions or any of the memory allocation macros in MASM32.

For all of the alternatives, I prefer the "alloc" macro and the "free" macro noting the case difference from the COM versions as they are both easy to use, fast and can handle any amount orf memory.
Title: Re: Malloc masm32 library problem
Post by: bsdsource on January 15, 2014, 01:31:51 AM
Guess I found some errors in the help file then. Maybe an update is in order for the next release of masm32.
Title: Re: Malloc masm32 library problem
Post by: hutch-- on January 15, 2014, 07:38:41 AM
 :biggrin:

The help file has been updated long ago and the two functions are only there for backwards compatibility for folks who may have used them. There are better, faster and easier to use capacities in both Windows and the MASM32 SDK. They are not in the help file as they are no longer supported.