Hi Jarkko,
Here is that the SUSV2 prescribe to do in this situation.
The Single UNIX ® Specification, Version 2, Copyright © 1997 The Open Group
"
NAME
malloc - a memory allocator
...
RETURN VALUE
Upon successful completion with size not equal to 0, malloc() returns a pointer
to the allocated space. If size is 0, either a null pointer or a unique pointer
that
can be successfully passed to free() will be returned...
"
Happy coding,
Timur Safin
mailto:[EMAIL PROTECTED] http://timur.lanit.ru
mailto:[EMAIL PROTECTED]
ICQ: 67086553
----- Original Message -----
From: "Jarkko Hietaniemi" <[EMAIL PROTECTED]>
To: "Gibbs Tanton - tgibbs" <[EMAIL PROTECTED]>
Cc: "'Josh Wilmes '" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Monday, September 17, 2001 11:36 PM
Subject: Re: "Automated" Purify Run
: On Mon, Sep 17, 2001 at 02:30:22PM -0500, Gibbs Tanton - tgibbs wrote:
: > Well, that explains the last Purify issue. Whenever we substr out 0 bytes
: > to a NULL register, we create a string by malloc(0). If we later print that
:
: Not so. Depending on the implementation malloc(0) may do any of
: the following:
:
: (1) return a unique pointer
: (2) return NULL
: (3) crash
: (4) return a pointer to a naughty address so that we'll crash later
: (5) return a pointer to the collected works of Herodotos
:
: Of course, in practice only the two first choices are often seen.
: But both are possible.
:
: > string, then we pass in 0 to printf. I thought that printf would not look
: > at its argument if the length specifier was 0, but apparently on your system
: > it does. So, it appears we have two options:
: >
: > 1.) Ignore the error
: >
: > 2.) Put an if statement around the print and have it not print if the
: > string is of length 0.
:
: 3.) Do not use malloc(0).
:
: --
: $jhi++; # http://www.iki.fi/jhi/
: # There is this special biologist word we use for 'stable'.
: # It is 'dead'. -- Jack Cohen
: