🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #49658

realloc(null, some_positive_number)

#49658
From: mla
Date: Wed, 12 Jan 1994 19:06
21 lines
1502 bytes
Hi,

This may not be a bug, but ignorance on my part, so please forgive!!

I am using gcc version 2.5.7.   In one of my calls to realloc, the first
parameter happened to be NULL.   As far as I can tell, a program compiled
with gcc will always return NULL from this call.  According to the 3 different
C books I have, when the first parameter is NULL, it should basically 
behave as malloc, i.e. allocate the memory requested if possible.  A simple
program trying to only allocate 1 byte always fails if the first parameter
is NULL (but malloc'ing works).  Is there a newer version of gcc that
fixes this problem?  With every other compiler I try (on the PC as well as
UNIX) I am able to get the memory, but I'd much rather use gcc!!   

I do have a work-around..."myrealloc" which checks the first parameter, if
NULL calls malloc, else calls realloc....


Thanks!
Melissa
Technical Details
Message-ID: <CJIyI8.n2n@topdown.com>
Path: arc1-ca.pugleaf.net!gmd.de!xlink.net!zib-berlin.de!netmbx.de!Germany.EU.net!EU.net!howland.reston.ans.net!noc.near.net!mv!topdown!news

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,bed32f990753bf29,start
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1994-01-12 09:38:10 PST
Newsgroups: gnu.gcc.help
Path: arc1-ca.pugleaf.net!gmd.de!xlink.net!zib-berlin.de!netmbx.de!Germany.EU.net!EU.net!howland.reston.ans.net!noc.near.net!mv!topdown!news
From: mla@topdown.com
Subject: realloc(null, some_positive_number)
Content-Type: TEXT/PLAIN; charset=US-ASCII
Message-ID: <CJIyI8.n2n@topdown.com>
Sender: news@topdown.com
Organization: Topdown Design Solutions
Mime-Version: 1.0
Date: Wed, 12 Jan 1994 19:06:29 GMT
Lines: 22