From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1014db,c617820a3952d228,start X-Google-Attributes: gid1014db,public X-Google-Thread: fee84,c617820a3952d228,start X-Google-Attributes: gidfee84,public From: biju@web1.calweb.com (Biju Srinivasan) Subject: Why does my C Realloc() fail? Date: 1998/04/09 Message-ID: <352d36a9.0@calwebnnrp>#1/1 X-Deja-AN: 342531117 X-NNTP-Posting-Host: news.calweb.com Organization: none XPident: Unknown Newsgroups: comp.lang.c,comp.unix.osf.osf1 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 #include #include #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