Mail Archives: djgpp/1992/08/12/09:03:11
Pieter Kunst writes:
> (2) The atexit() function (K&R, 2nd ed., p.253) returns garbage
> instead of the expected 0 if successful. (I think this was not
> the case in version 1.05 of DJGPP.)
The following patch should help.
Dieter
*** onexit.org Wed Aug 12 14:37:57 1992
--- onexit.c Wed Aug 12 14:43:14 1992
***************
*** 19,32 ****
void (*func)(int);
int arg;
{
struct atexit *a = (struct atexit *)malloc(sizeof(struct atexit));
a->next = __atexit;
a->function = func;
a->arg = arg;
__atexit = a;
}
atexit(a)
{
! on_exit(a,0);
}
--- 19,37 ----
void (*func)(int);
int arg;
{
+ if (func == 0)
+ return (-1);
struct atexit *a = (struct atexit *)malloc(sizeof(struct atexit));
+ if (!(*a))
+ return (-1);
a->next = __atexit;
a->function = func;
a->arg = arg;
__atexit = a;
+ return(0);
}
atexit(a)
{
! return(on_exit(a,0));
}
- Raw text -