News:

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

Memory Allocation

Started by Posit, May 17, 2005, 01:12:53 AM

Previous topic - Next topic

Posit

Do the MASM32 memory allocation routines simply make Windows API calls to HeapAlloc(), HeapReAlloc(), and HeapFree()? Since the calls will be from a C program, I would like to avoid the overhead of an extra function call if the library functions are simply wrappers over the API, since I can call the API functions directly from C.

Mark Jones

My first experience with memory allocation was with the GlobalAlloc API. In Win32 Global and LocalAlloc are the same thing. It works well and is easy to use. Any allocation must be freed before exit of course, dunno if C does this automatically but MASM does not. For more capability, see VirtualAlloc. Also a user here has made a SmallAlloc library which is useful for efficiently storing many small chunks of memory, search for it if interested.
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

hutch--

Posit,

If your program design in C requires it to allocate the memory, just pass a valid address to the masm prcedure and it should work fine.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Tedd

Yes the macros are just wrappers for api functions.
So I'd just use the heap function directly :wink

Mark - globalalloc/localalloc actually end up forwarding to heapalloc anyway :bdg
No snowflake in an avalanche feels responsible.