Author Topic: Malloc masm32 library problem  (Read 5466 times)

bsdsource

  • Regular Member
  • *
  • Posts: 33
Malloc masm32 library problem
« 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?

jj2007

  • Member
  • *****
  • Posts: 10446
  • Assembler is fun ;-)
    • MasmBasic
Re: Malloc masm32 library problem
« Reply #1 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

bsdsource

  • Regular Member
  • *
  • Posts: 33
Re: Malloc masm32 library problem
« Reply #2 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

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 7449
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Malloc masm32 library problem
« Reply #3 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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

bsdsource

  • Regular Member
  • *
  • Posts: 33
Re: Malloc masm32 library problem
« Reply #4 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.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 7449
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Malloc masm32 library problem
« Reply #5 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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy: