delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/05/14/02:01:35

From: steve DOT greenland AT aspentech DOT com (Steve Greenland)
Subject: RE: strlen on a NULL
14 May 1998 02:01:35 -0700 :
Message-ID: <C70EADA6FA77D111852700805FBB7473210298.cygnus.gnu-win32@max.aco.aspentech.com>
Mime-Version: 1.0
To: gnu-win32 AT cygnus DOT com

> -----Original Message-----
> From: Carsten DOT Roedel AT rt DOT bosch DOT de [mailto:Carsten DOT Roedel AT rt DOT bosch DOT de]
> Sent: Wednesday, May 13, 1998 1:14 AM
>
> By the way, in 'free' it's getting worse,
> because you must also check not for pointing to a 'Zero', 
> this causes a crash. 

I'm not sure exactly what you mean by this phrase, but 
free(NULL) *is* defined: it's a no-op. If your implementation
crashes or otherwise misbehaves when you make the call "free(NULL)"
(or an equivalent), then the implementation is broken (assuming it
claims to be ISO C compliant, of course). 

Note that the sequence 

char *a = malloc(5);
free(a);
free(a);

*is* undefined; <a> is NOT set to NULL by the first call to free (how
could
it be?) but it does make the value of a invalid; the second call to free
attempts to free an invalid pointer...

Steve
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019