[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: emacs' turn: remove useless if-before-free tests
From: |
YAMAMOTO Mitsuharu |
Subject: |
Re: emacs' turn: remove useless if-before-free tests |
Date: |
Mon, 02 Jun 2008 11:34:23 +0900 |
User-agent: |
Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (Shijō) APEL/10.6 Emacs/23.0.50 (sparc-sun-solaris2.8) MULE/5.0 (SAKAKI) |
>>>>> On Mon, 02 Jun 2008 11:05:55 +0900, Miles Bader <address@hidden> said:
>> I guess the acceptance of NULL for `free' in POSIX is the
>> reflection of the fact that `malloc' may return NULL. If so, we
>> could take a different policy for `xfree', i.e., abort if NULL,
>> because `xmalloc' may not return NULL unlike malloc. This may help
>> us detect the behavior that is different from programmer's
>> intention.
> xmalloc can return NULL.
IIUC, only when the SIZE argument is 0. I think many programmers have
never cared about the NULL-check of the return value of xmalloc where
they are sure that its argument is positive. Also we could make
xmalloc to return a non-NULL value for the case SIZE==0.
> I think xmalloc and xfree should act as much like posix malloc/free
> as possible, modulo the error-handling behavior of xmalloc. That
> will be the least surprising to programmers using them. Indeed, we
> can make them act like the posix function even on systems whose
> native malloc is less so.
That would be one policy. What I said is just another possible policy
that could make use of the explicit distinction between `if (p) xfree
(p)' and `xfree (p)' programmers have been made rather than losing
such information just for cleanup.
YAMAMOTO Mitsuharu
address@hidden
- Re: emacs' turn: remove useless if-before-free tests, (continued)
Re: emacs' turn: remove useless if-before-free tests, Richard M Stallman, 2008/06/01
Re: emacs' turn: remove useless if-before-free tests, Stefan Monnier, 2008/06/01
Re: emacs' turn: remove useless if-before-free tests, Stefan Monnier, 2008/06/01
Re: emacs' turn: remove useless if-before-free tests, Jim Meyering, 2008/06/02