|
|
1.1 ! root 1: /* ! 2: * miscellaneous error handling ! 3: */ ! 4: ! 5: #include <stdio.h> ! 6: ! 7: extern char *malloc(), *realloc(); ! 8: ! 9: char * ! 10: emalloc(size) ! 11: int size; ! 12: { ! 13: char *p; ! 14: ! 15: if ((p = malloc(size)) == NULL) ! 16: panic("out of memory\n"); ! 17: return (p); ! 18: } ! 19: ! 20: char * ! 21: erealloc(p, size) ! 22: char *p; ! 23: int size; ! 24: { ! 25: if ((p = realloc(p, size)) == NULL) ! 26: panic("out of memory\n"); ! 27: return (p); ! 28: } ! 29: ! 30: /* ! 31: * print to the log (== standard error) ! 32: */ ! 33: ! 34: log(s, p0, p1, p2, p3, p4, p5) ! 35: char *s; ! 36: { ! 37: char *ctime(); ! 38: long time(); ! 39: long now; ! 40: ! 41: time(&now); ! 42: fprintf(stderr, "%.15s ", ctime(&now)+4); ! 43: fprintf(stderr, s, p0, p1, p2, p3, p4, p5); ! 44: fflush(stderr); ! 45: } ! 46: ! 47: /* ! 48: * fatal error: log and exit ! 49: */ ! 50: panic(s, p0, p1, p2, p3, p4, p5) ! 51: char *s; ! 52: { ! 53: char *ctime(); ! 54: long time(); ! 55: long now; ! 56: ! 57: time(&now); ! 58: fprintf(stderr, "%.15s panic:", ctime(&now)+4); ! 59: fprintf(stderr, s, p0, p1, p2, p3, p4, p5); ! 60: fflush(stderr); ! 61: exit(1); ! 62: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.