Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* Why does my C Realloc() fail?
@ 1998-04-09  4:00 Biju Srinivasan
  1998-04-09  4:00 ` Dann Corbit
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Biju Srinivasan @ 1998-04-09  4:00 UTC (permalink / raw)



Platform = DEC Alpha (OSF1 V4.0)
Why does my C realloc() fail?
A single malloc works for as big as 134 MBytes.
Realloc fails for a size of 101 MBytes following an alloc of 100 MBytes.
Doesn't realloc claim the space assigned to the original pointer and add
extra space to it?

I get the following error when i run the following piece of code
"Error in realloc:: Not enough space"

Begin: Include Code
==========
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#define STR_LEN   134000000      A single malloc with this size succeeds.
#define STR_LEN1 100000000
#define STR_LEN2 101000000
main()
{
    char *tStr;
    if((tStr = (char *)malloc(STR_LEN1)) == NULL)
        perror("Error in malloc:");
    if((tStr = (char *)realloc(tStr, STR_LEN2)) == NULL)
        perror("Error in realloc:");
}
==========
End: Include Code

Thanks,
-Biju
biju@calweb.com



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1998-04-22  4:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1998-04-09  4:00 Why does my C Realloc() fail? Biju Srinivasan
1998-04-09  4:00 ` Dann Corbit
1998-04-10  4:00 ` Exil Q Trob
1998-04-10  4:00 ` Christopher Green
1998-04-11  4:00 ` Mark Brown
1998-04-22  4:00 ` Jeff Donsbach

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox