aboutsummaryrefslogtreecommitdiffstats
path: root/src/util.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2017-07-23 20:48:18 +0200
committerMattias Andrée <maandree@kth.se>2017-07-23 20:48:18 +0200
commitccd26e2affb0fb4a10b7261a85cb85b2525e5d9e (patch)
tree0f83f5850f4a175b437ff271c5cac1dd65781213 /src/util.c
parentAdd blind-colour-matrix, and blind-invert-matrix: fix -e and add -axyz (diff)
downloadblind-ccd26e2affb0fb4a10b7261a85cb85b2525e5d9e.tar.gz
blind-ccd26e2affb0fb4a10b7261a85cb85b2525e5d9e.tar.bz2
blind-ccd26e2affb0fb4a10b7261a85cb85b2525e5d9e.tar.xz
Fix some errors, add manual for blind-colour-matrix and add blind-primary-key
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--src/util.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/util.c b/src/util.c
index 3e03b67..3fc3716 100644
--- a/src/util.c
+++ b/src/util.c
@@ -158,16 +158,18 @@ getfile(int fd, void *buffer, size_t *restrict ptr, size_t *restrict size)
{
char *restrict *restrict buf = buffer;
void *new;
+ size_t new_size;
ssize_t r;
for (;;) {
if (*ptr == *size) {
- if (!(new = realloc(*buf, *size << 1))) {
+ new_size = *size ? *size << 1 : BUFSIZ;
+ if (!(new = realloc(*buf, new_size))) {
errno = ENOMEM;
return -1;
}
*buf = new;
- *size <<= 1;
+ *size = new_size;
}
r = read(fd, *buf + *ptr, *size - *ptr);
if (r <= 0) {