home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
MM1
/
SOUNDUTILS
/
mm1_tracker.lzh
/
TRACKER4.6
/
autoinit.c
< prev
next >
Wrap
Text File
|
1994-11-24
|
965b
|
60 lines
/* autoinit.c
vi:ts=3 sw=3:
*/
/* $Id: autoinit.c,v 4.4 1994/11/15 16:11:01 espie Exp espie $
* $Log: autoinit.c,v $
* Revision 4.4 1994/11/15 16:11:01 espie
* *** empty log message ***
*
*/
#include <stdio.h>
#include <stdlib.h>
#include "defs.h"
#include "extern.h"
ID("$Id: autoinit.c,v 4.4 1994/11/15 16:11:01 espie Exp espie $")
LOCAL struct clist
{
struct clist *next;
void (*func) P((void));
} *list = 0;
void at_end(cleanup)
void (*cleanup) P((void));
{
#ifdef USE_AT_EXIT
atexit(cleanup);
#else
struct clist *new;
new = (struct clist *)malloc(sizeof(struct clist));
if (!new)
{
(*cleanup)();
end_all("Allocation problem");
}
new->next = list;
new->func = cleanup;
list = new;
#endif
}
void end_all(s)
char *s;
{
#ifndef USE_AT_EXIT
struct clist *p;
#endif
if (s)
notice(s);
#ifndef USE_AT_EXIT
for (p = list; p; p = p->next)
(p->func)(); /* don't bother freeing (malloc) */
#endif
exit(s ? 10 : 0);
}