|
-
May 14th, 1999, 03:31 AM
#1
_msize()
I noticed really weird bug in VC (6.0 SP2).
void *aa=malloc(0);
long bb=_msize(aa);
In Debug Build, _msize returns correct value - 0, but in Release Build, 12 is returned!
I don't think this is correct behaviour, and, AFAIR, _msize() functioned just fine until two weeks ago. Where is the problem?
- Goran.
-
May 14th, 1999, 07:24 AM
#2
Re: _msize()
_msize
Returns the size of a memory block allocated in the heap.
malloc(size)
The malloc function allocates a memory block of at least size bytes. The block may be larger than size bytes because of space required for alignment and maintenance information.
So, as you can see, malloc might actually allocate a block size that's larger than the amount you requested. When this happens you are free to use the whole allocated block, and _msize is twlling you how much space you actually have. So even though you allocated 0 byes, you have been given 12 bytes and may use all those 12 bytes if you wish.
--
Daren Chandisingh
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|