home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / gnu / djgpp / libsrc / c / lib / onexit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-28  |  963 b   |  39 lines

  1. /*
  2. ** Copyright (C) 1993 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
  3. **
  4. ** This file is distributed under the terms listed in the document
  5. ** "copying.dj", available from DJ Delorie at the address above.
  6. ** A copy of "copying.dj" should accompany this file; if not, a copy
  7. ** should be available from where this file was obtained.  This file
  8. ** may not be distributed without a verbatim copy of "copying.dj".
  9. **
  10. ** This file is distributed WITHOUT ANY WARRANTY; without even the implied
  11. ** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. */
  13.  
  14. #include <atexit.h>
  15.  
  16. struct atexit *__atexit = 0;
  17.  
  18. on_exit(func,arg)
  19. void (*func)(int);
  20. int arg;
  21. {
  22.   struct atexit *a;
  23.   if (func == 0)
  24.     return -1;
  25.   a = (struct atexit *)malloc(sizeof(struct atexit));
  26.   if (!a)
  27.     return -1;
  28.   a->next = __atexit;
  29.   a->function = func;
  30.   a->arg = arg;
  31.   __atexit = a;
  32.   return 0;
  33. }
  34.  
  35. atexit(a)
  36. {
  37.   return on_exit(a,0);
  38. }
  39.