commit: ce8cba0c158fab9fbaa5afc4e952e9fdd717db98
parent: 36fae0a9fab3e39356f26cd136b3874f98ac56bf
author: Chris Noxz <chris@noxz.tech>
date: Sun, 15 Sep 2019 11:19:03 +0200
Move freeing of `cols` and remove some redundancy
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/bfck.c b/bfck.c
@@ -158,13 +158,14 @@ run()
break;
}
}
+ free(cols);
}
void
load(const char *fn)
{
int b, n = 0;
- char buf[1024], *p = 0;
+ char buf[1024];
FILE *f = NULL;
if (!(f = fopen(fn, "r")))
@@ -172,12 +173,11 @@ load(const char *fn)
while (!feof(f)) {
b = fread(buf, 1, sizeof buf, f);
- if (!(p = (char *)realloc(p, (n += b) + 1)))
+ if (!(bf = (char *)realloc(bf, (n += b) + 1)))
exit(1);
- memcpy(p + n - b, buf, b);
+ memcpy(bf + n - b, buf, b);
}
fclose(f);
- bf = p;
}
int
@@ -185,5 +185,4 @@ main(int argc, char *argv[])
{
load(argv[1]);
run();
- free(cols);
}