util.h (501B)
1 #ifndef __UTIL_H_ 2 #define __UTIL_H_ 3 #define allocztn(type, n) allocz(sizeof(type) * n) 4 #define alloczt(type) allocz(sizeof(type)) 5 6 typedef struct mctx { 7 int ptrc; 8 void **ptrs; 9 } mctx; 10 11 extern mctx *gctx; 12 13 void *alloczctx(mctx *ctx, const size_t size); 14 void *realloczctx(mctx *ctx, void *ptr, const size_t size); 15 void *reallocz(void *ptr, const size_t size); 16 void *allocz(const size_t size); 17 mctx *newctx(); 18 void freectx(mctx *ctx); 19 char *strslice(char *s, int len); 20 char *drainfile(FILE *f); 21 #endif