News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Malloc masm32 library problem

Started by bsdsource, January 13, 2014, 09:33:20 AM

Previous topic - Next topic

bsdsource

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?

jj2007

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

bsdsource

I'm surprised that information is not in the masm32 lib help file. Thank you for the help.  :t

hutch--

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.

bsdsource

Guess I found some errors in the help file then. Maybe an update is in order for the next release of masm32.

hutch--

 :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.