home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fred Fish Collection 1.5
/
ffcollection-1-5-1992-11.iso
/
ff_disks
/
100-199
/
ff114.lzh
/
WBLander
/
Source
/
cleanup.c
< prev
next >
Wrap
C/C++ Source or Header
|
1987-11-22
|
631b
|
39 lines
#include <exec/memory.h>
struct _clean {
int (*function)();
char *name;
struct _clean *next;
} *cleanlist = NULL;
add_cleanup(function, name)
int (*function)();
{
struct _clean *ptr;
ptr = AllocMem(sizeof(struct _clean), MEMF_PUBLIC);
if(!ptr)
return 0;
ptr->function = function;
ptr->name = name;
ptr->next = cleanlist;
cleanlist = ptr;
}
cleanup(debug)
int debug;
{
struct _clean *ptr;
int (*f)();
while(cleanlist) {
ptr = cleanlist;
cleanlist = cleanlist->next;
f = ptr->function;
if(debug == 1)
printf("Cleanup: removing '%s'\n", ptr->name);
FreeMem(ptr, sizeof(struct _clean));
(*f)();
}
}