🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #2796

Re: realloc

#2796
From: Jim Patterson
Date: Tue, 23 Apr 1991 14:12
24 lines
1308 bytes
In article <91112.102011LSC@SLACVM.SLAC.STANFORD.EDU> LSC@SLACVM.SLAC.STANFORD.EDU writes:
>Hi,
>     In the ANSI standard, p 155 line 23, it says:
>
>     "If the space cannot be allocated, the object pointed to by ptr is unchang
>unchanged."
>
>     Does this mean that one has no means of checking the success or failure
>of the operation? Does one have to resort to errno?

Check 4.10.3 (page 155 line 17 in mine; I think yours is different). It
says

   If the space cannot be allocated, a null pointer is returned.

So, hang on to your original pointer. realloc shouldn't free the space
it points to if it fails, but it may appear to because it will return
a null pointer value.

-- 
Jim Patterson                              Cognos Incorporated
UUCP:uunet!mitel!cunews!cognos!jimp        P.O. BOX 9707    
PHONE:(613)738-1440 x6112                  3755 Riverside Drive
                                           Ottawa, Ont  K1G 3Z4
Technical Details
Message-ID: <9559@cognos.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!cunews!cognos!jimp
References: <91112.102011LSC@SLACVM.SLAC.STANFORD.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!cunews!cognos!jimp
From: jimp@cognos.UUCP (Jim Patterson)
Newsgroups: comp.std.c
Subject: Re: realloc
Message-ID: <9559@cognos.UUCP>
Date: 23 Apr 91 14:12:40 GMT
References: <91112.102011LSC@SLACVM.SLAC.STANFORD.EDU>
Reply-To: jimp@cognos.UUCP (Jim Patterson)
Organization: Cognos Inc., Ottawa, Canada
Lines: 24