realloc

Jim Patterson jimp at cognos.UUCP
Wed Apr 24 00:12:40 AEST 1991


In article <91112.102011LSC at SLACVM.SLAC.STANFORD.EDU> LSC at 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



More information about the Comp.std.c mailing list