From 329ccb0947fed5c6e141912aad04afec2673b636 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sun, 1 Dec 2013 17:44:34 +0000 Subject: cleanup --- bf.c | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/bf.c b/bf.c index f15d3fc..9302c59 100644 --- a/bf.c +++ b/bf.c @@ -15,7 +15,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include #include #include #include @@ -36,7 +35,8 @@ alloccell(void) Cell *c; c = calloc(1, sizeof(Cell)); - assert(c); + if (!c) + errx(1, "calloc"); return c; } @@ -77,14 +77,15 @@ freadall(char *fname) fd = fopen(fname, "r"); if (!fd) - return NULL; + errx(1, "cannot open %s", fname); fseek(fd, 0L, SEEK_END); len = ftell(fd); fseek(fd, 0L, SEEK_SET); buf = calloc(len + 1, sizeof(char)); - assert(buf); + if (!buf) + errx(1, "calloc"); fread(buf, sizeof(char), len, fd); fclose(fd); @@ -102,23 +103,6 @@ usage(void) exit(1); } -char * -walk(char **j, char *p) -{ - for (; *p; p++, j++) - switch (*p) { - case '[': - *j = walk(j + 1, p + 1); - break; - case ']': - return p; - default: - break; - } - - return NULL; -} - char * locatejmp(char *prog) { -- cgit v1.2.3