/* * alloc: heap allocation routines * * zmark() * zrelease() * zalloc() * zfile() * zmrealloc() * zunalloc() * zstrdup() */ #include #include "tsh.h" extern char *mmalloc(); extern char *mrealloc(); extern void mfree(); typedef struct { char *ptr; int flag; #define ISAFILE 0x01 /* this ptr points at a internal file that we */ /* need to kill */ } mark; static mark *markarray=(mark*)0; static int markcount=0; /* * zmark() sets a heap mark */ zmark() { fprintf(stderr, "mark %d\n", markcount); return markcount; } /* zmark */ /* * zrelease() mfrees all memory since a zmark */ zrelease(mk) { register i; fprintf(stderr, "release to %d\n", mk); for (i=mk; i