Hi,
I want to make a String within a Proc with a length of strlen(xyz).
So my question: Is there something like (char *)var malloc(strlen(xyz) + 1)
in C?
Yes, there is. Check \masm32\help\hlhelp.hlp, String macros, Allocating String Buffers
noob,
In the simple sense of using provided macros, try something like this.
; byte count required = 4096 ; pick your size as needed
mov hMem, alloc(4096)
; do something with the memory
free hMem
It is worth understanding what is behind macros of this type, there are multiple strategies in memory allocation for different asks.
VirtualAlloc(), HeapAlloc(), GlobalAlloc(), OLE string memory and a few others. Each comes with a matching realloc and free.
hi.
Any recommendations or tips as to what memory allocation functions to use when & where ?
thanks
There is a bit of personal preference in this area. For fixed address single contiguous memory I still prefer GlobalAlloc() with the GMEM_FIXED flag. If I am bashing string data around in a hurry I use OLE string. VirtualAlloc() handles very large blocks well but is badly suited for small repeated allocations. I rarely ever use HeapAlloc() but it does the job fine if you want more of a dos C style of memory control.