realloc down

realloc down

Post by Vic Dur » Mon, 06 Jan 2003 07:12:12



Hello,

I'm using the lccwin32 compiler on win98se. I've notice when I use
realloc to down-size a memory block, that the resulting memory block
is often (not always) larger than the requested down-size. For
example:  

root = malloc (2000);

will allocate a 2000 byte block as shown by _msize (root).  But then
when I

root = realloc (root, (size_t) 2);

the size as shown by _msize (root) is 12 bytes rather than the  2
bytes that I expected.

I'm trying to understand how all this works and I was wondering if
anyone here could be so kind as to enlighten me.

Thanks for any comments.

Regards,
Vic Dura

--
Performing Arts in the Shoals Area
Shoals Symphony Orchestra at UNA: http://www.ShoalsSymphony.org/
Opera South: http://www.OperaSouth.org/

 
 
 

realloc down

Post by John » Mon, 06 Jan 2003 16:42:52



Quote:> Hello,

> I'm using the lccwin32 compiler on win98se. I've notice when I use
> realloc to down-size a memory block, that the resulting memory block
> is often (not always) larger than the requested down-size. For
> example:

> root = malloc (2000);

> will allocate a 2000 byte block as shown by _msize (root).  But then
> when I

> root = realloc (root, (size_t) 2);

> the size as shown by _msize (root) is 12 bytes rather than the  2
> bytes that I expected.

> I'm trying to understand how all this works and I was wondering if
> anyone here could be so kind as to enlighten me.

The only requirement in this regard for memory allocation functions is that,
provided the call is successful, it supplies at least the requested size. In
practice this means the size is usually rounded up to a 16 byte boundary.
This is to ensure that all allocations are suitably aligned for any object.

John

 
 
 

realloc down

Post by Vic Dur » Tue, 07 Jan 2003 03:23:24


On Sun, 5 Jan 2003 07:42:52 -0000,  RE: Re: realloc down  "John"




>> Hello,

>> I'm using the lccwin32 compiler on win98se. I've notice when I use
>> realloc to down-size a memory block, that the resulting memory block
>> is often (not always) larger than the requested down-size. For
>> example:

>> root = malloc (2000);

>> will allocate a 2000 byte block as shown by _msize (root).  But then
>> when I

>> root = realloc (root, (size_t) 2);

>> the size as shown by _msize (root) is 12 bytes rather than the  2
>> bytes that I expected.

>> I'm trying to understand how all this works and I was wondering if
>> anyone here could be so kind as to enlighten me.

>The only requirement in this regard for memory allocation functions is that,
>provided the call is successful, it supplies at least the requested size. In
>practice this means the size is usually rounded up to a 16 byte boundary.
>This is to ensure that all allocations are suitably aligned for any object.

>John

Ah, I see. Then this rounding-up may be what I am seeing.

Thanks for the comments.

Regards,
Vic Dura

--
Performing Arts in the Shoals Area
Shoals Symphony Orchestra at UNA: http://www.ShoalsSymphony.org/
Opera South: http://www.OperaSouth.org/

 
 
 

1. about realloc memo in TornadoII

Hi Vxwork guru...

  I have  a quetion that what different between Win32 and Tonardo..
we can get buffer according to our requirement in Win32, but I do not know how about Tornado..
can anyone tell me...

 for example:
   we can define a array with following:
    #define    BUFSIZE    1024
       char    buffer[BUFSIZE];

 we will not get the right result in Tornado..

can anyone help me?
Best wish

2. How to display Japanese and Korean Characters in mule-19.33-gamma

3. Memory allocation and realloc

4. error messages

5. A problem with realloc

6. Removable hard disks

7. Memory fragmentation with realloc()

8. Is there an internet phone app for Warp?

9. realloc bug in MSL?

10. realloc freed memory

11. realloc problem

12. Shut down automatilally my PC when another PC shuts down

13. To power down or not to power down...