[EMAIL PROTECTED] (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 [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to