Date: 20 Dec 2000 20:33:08 +0100 From: Assar Westerlund <assar@FreeBSD.ORG> To: seebs@plethora.net (Peter Seebach) Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: Why not another style thread? (was Re: cvs commit: src/lib/libc/gen .. Message-ID: <5l3dfiyjkb.fsf@assaris.sics.se> In-Reply-To: seebs@plethora.net's message of "Wed, 20 Dec 2000 09:41:11 -0600" References: <200012201541.JAA15236@guild.plethora.net>
next in thread | previous in thread | raw e-mail | index | archive | help
seebs@plethora.net (Peter Seebach) writes: > Okay, from a style standpoint, the basic problem is that this function > is a mistake. No, I use a function like that (called emalloc) all the time, when I know there's nothing better to do than exit. > Programs may have temp files open, they may have stty > settings to reset, there are tons of things you may need to do *BEFORE > EXITING*. atexit > At a bare minimum, the Correct Thing would be > #define safe_malloc(x) safe_malloc_internal((x), __FILE__, __LINE__) > > void *safe_malloc(size_t bytes, char *file, int line) > { > void *p = malloc(bytes); > if (p == NULL) { > fprintf(stderr, "can't allocate %lu bites at file %s, line %d.", > (unsigned long) x, __FILE__, __LINE__); s/__FILE__/file/, s/__LINE__/line/ > (In an ideal world, you'd have the program name in here.) err(3) ? /assar To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5l3dfiyjkb.fsf>