From: biju@web1.calweb.com (Biju Srinivasan)
Subject: Why does my C Realloc() fail?
Date: 1998/04/09 [thread overview]
Message-ID: <352d36a9.0@calwebnnrp> (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
next reply other threads:[~1998-04-09 4:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-04-09 4:00 Biju Srinivasan [this message]
1998-04-09 4:00 ` Why does my C Realloc() fail? Dann Corbit
1998-04-10 4:00 ` Christopher Green
1998-04-10 4:00 ` Exil Q Trob
1998-04-11 4:00 ` Mark Brown
1998-04-22 4:00 ` Jeff Donsbach
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox