Helo :) This question is pretty basic... If I allocated lots of space and need to enlarge it I call GlobalReAlloc.. This goes like this: GlobalAlloc GlobalLock ... GlobalReAlloc GlobalLock $10 Question: can I move the eax returned by GlobalReAlloc into the same memory handle I got from GlobalAlloc? Or should I use two different handles? $20 Question: Can I call GlobalUnlock/GlobalFree with the pointer/handle returned by GlobalAlloc after calling GlobalReAlloc making the return value into another handle? Thanks - Jimmy
Well my $1 answer is do't use Globalxxx functions, they are obsolete, use Heap... functions instead :)
now DataPtr, points to 1024 bytes of zero'd RAM Umbongo
invoke GetProcessHeap mov hHeap,eax invoke HeapAlloc,hHeap,HEAP_ZERO_MEMORY,1024 mov DataPtr,eax
Invoking GlobalReAlloc will replace the old handle. In otherwords, the old handle is invalid, and the new one is the only one that can be used with other Global*** functions. Can I have my $30 now :P Mirno
the GlobalRealloc function is the only one, which preserves the contents of the memory block! If you need this feature, you must use the GlobalXXX API. By the way, also the HeapXXX API is not state of the (MS) art, the most common one is the VirtualXXX.
Virtualxxx is the lowest level interface for memory management in the Win32 API. Heapxxx uses Virtualxxx. Globalxxx and Localxxx uses Heapxxx. Globalxxx and Localxxx were implemented primarily for source code compatibility with Win16 programs. Some versions of VC++ implement malloc as a call to HeapAlloc. This message was edited by tank, on 4/5/2001 7:00:18 PM