Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 Jul 2001 02:37:41 +0100
From:      Brian Somers <brian@Awfulhak.org>
To:        Assar Westerlund <assar@FreeBSD.org>
Cc:        Brian Somers <brian@Awfulhak.org>, cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/lib/libutil ecalloc.c emalloc.3 emalloc.c erealloc.c estrdup.c Makefile libutil.h 
Message-ID:  <200107230137.f6N1bfg13122@hak.lan.Awfulhak.org>
In-Reply-To: Message from Assar Westerlund <assar@FreeBSD.org>  of "23 Jul 2001 03:03:54 %2B0200." <5lhew4h2x1.fsf@assaris.sics.se> 

next in thread | previous in thread | raw e-mail | index | archive | help
> Brian Somers <brian@Awfulhak.org> writes:
> > What a bizarre idea.  IMHO this is not necessary.  Was this discussed 
> > somewhere ?
> 
> Why is this bizarre?  Is it better having these functions in lots of
> different programs under different names?  I sent a mail about this to
> freebsd-audit@freebsd.org.

This sort of function should be thrown out in a code review on the 
basis that it obfuscates the code.

  ptr = emalloc(n);

will mean nothing to a regular C programmer (except that it's 
probably doing a malloc with some extra stuff).

  if ((ptr = malloc(n)) == NULL)
    errx(1, "malloc %lu failed", (unsigned long)n);

will mean much more (hmm, I'll bet errx() exits, I wonder what the 
``1'' is for?), and

  if ((ptr = malloc(n)) == NULL) {
    fprintf(stderr, "malloc %lu failed\n", (unsigned long)n);
    exit(1);
  }

would actually be portable.

Adding routines such as these to our libraries and then using them 
from our programs just makes it irritating when you try to build 
something on another OS -- not to mention obfuscating our code base.

Of course I completely disagree with the err/errx/warn/warnx stuff 
too for exactly the same reasons -- having wanted to build things such 
as newsyslog to Solaris.

And before we know it, calls to things like this start slipping into 
our libraries... that way lies ruin !

> /assar

-- 
Brian <brian@freebsd-services.com>                <brian@Awfulhak.org>
      http://www.freebsd-services.com/        <brian@[uk.]FreeBSD.org>
Don't _EVER_ lose your sense of humour !      <brian@[uk.]OpenBSD.org>



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200107230137.f6N1bfg13122>