all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
To: Miles Bader <miles@gnu.org>
Cc: Emacs development discussions <emacs-devel@gnu.org>,
	Stefan Monnier <monnier@IRO.UMontreal.CA>,
	Jim Meyering <jim@meyering.net>
Subject: Re: emacs' turn: remove useless if-before-free tests
Date: Mon, 02 Jun 2008 11:34:23 +0900	[thread overview]
Message-ID: <wlprr0ftu8.wl%mituharu@math.s.chiba-u.ac.jp> (raw)
In-Reply-To: <buolk1oh9q4.fsf@dhapc248.dev.necel.com>

>>>>> On Mon, 02 Jun 2008 11:05:55 +0900, Miles Bader <miles.bader@necel.com> 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
				mituharu@math.s.chiba-u.ac.jp




  reply	other threads:[~2008-06-02  2:34 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-31 16:29 emacs' turn: remove useless if-before-free tests Jim Meyering
2008-06-01  1:25 ` Miles Bader
2008-06-01 11:10   ` Jim Meyering
2008-06-01 13:48     ` Miles Bader
2008-06-01 14:35       ` Jim Meyering
2008-06-01 14:51         ` David Kastrup
2008-06-01 15:57           ` Miles Bader
2008-06-01 14:03 ` Richard M Stallman
2008-06-01 14:22   ` Jim Meyering
2008-06-02 10:54     ` Richard M Stallman
2008-06-02 11:22       ` Jim Meyering
2008-06-01 21:41 ` Stefan Monnier
2008-06-02  0:56   ` YAMAMOTO Mitsuharu
2008-06-02  2:05     ` Miles Bader
2008-06-02  2:34       ` YAMAMOTO Mitsuharu [this message]
2008-06-02 16:30         ` Richard M Stallman
2008-06-02  2:26     ` Stefan Monnier
2008-06-02  6:14   ` Jim Meyering
2008-06-08 10:53     ` Emanuele Giaquinta
2008-06-08 12:31       ` Jim Meyering
2008-06-10 10:25         ` Jim Meyering
2008-06-12 22:54           ` Jim Meyering

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=wlprr0ftu8.wl%mituharu@math.s.chiba-u.ac.jp \
    --to=mituharu@math.s.chiba-u.ac.jp \
    --cc=emacs-devel@gnu.org \
    --cc=jim@meyering.net \
    --cc=miles@gnu.org \
    --cc=monnier@IRO.UMontreal.CA \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.