>Hi,
>
>On the docs, MemHandleSize is stated as returning 'the requested size of
>a chunk'. Does this mean that if I resize a chunk, MemHandleSize will
>return the old size?
>
>In pseudo-code:
>     h = MemHandleNew(10);  // Alloc 10 byte chunk
>     MemHandleResize(hm 20); // Resize it to 20
>                                                 // And now for the big
>finale
>     MemHandleSize(h); // What is the return value for MemHandleSize? 10
>or 20?

You will get the current size of the handle based on your last size 
request- in the above case, calling MemHandleSize after the 
MemHandleNew would return 10, and after the resize (assuming it was 
successful) it would return 20.

The statement about the requested size is because

1. the OS may actually allocate more memory than you requested to 
keep the block an even size and aligned.
2. the OS always allocates a little extra memory for each block for 
the chunk header (this is how the OS knows who owns the block, the 
current lock count, etc.).

Fortunately, the OS shields you from the details and just gives you 
what you ask for - the size you care about.

JB

Reply via email to