I don't see much value in the LocalAlloc function, e.g. to get a small buffer for LoadString. Why not just define such buffers as uninitialized data?
Larry, LocalAlloc is an obselete function, GlobalAlloc is still current in win32. Main advantage with memory allocation functions is that you can set the amount you require at runtime. OLE string memory, GlobalAlloc, VirtualAlloc, Ernie Murphy has written an iMalloc interface for memory allocation as well. Regards, email@example.com
Hey, There is no reason to use LocalAlloc, its probably better to use a .bss section because windows can only allocate memory in page granuality (4096 bytes). This of course leads to a big waste of memory as most strings are only 30 - 100 bytes long. It is a good idea to declare a general purpose buffer.
imho its even better to use the stack for small buffers (no clue how small small is, but small is not large :)). the stack is your friend ;). some hll alike code: sub esp, size yourstruc mov ebp,esp mov eax, blabla add esp,size yourstruc and define somewhere your struc like struc yourstruc example dd ? ends
As I thought. sub esp,buffsize is natural but I will do an experiment on using absolute sites in ss for buffers -- often useful in DOS.
What about heapAlloc?
HeapAlloc what you are supposed to use over local and global alloc in win95. But buffers that you use over and over again in your code, putting it in the data? is easier to do. For small temporary buffers, the stack is better. For large temporary buffers, heapAlloc is better. But these functions are more suited for making linked lists and other realated structers than buffers to store temporary strings.