21.4. Memory

The 32-bit APIs contains its own memory allocation and deallocation functions. Normally you will use functions like new or malloc to allocate memory inside an application, but there are cases in which you must use the API calls. Probably the best example of a place where you must use the API allocation functions is inside a DLL, where a call to new fails.

The APIs contains two identical sets of memory allocation functions. One starts with Local (e.g. LocalAlloc), while the other starts with Global (e.g. GlobalAlloc). In older versions of Windows, the two sets had different uses, but in Windows they are identical and completely interchangeable.

Use the GlobalAlloc and GlobalFree functions to allocate or deallocate a block of memory ...

Get Win32 System Services: The Heart of Windows® 98 and Windows® 2000 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.