From: vhanquez@kneesa.uk.xensource.com Date: Tue, 24 Jan 2006 10:52:52 +0000 (+0000) Subject: fixup reallocation to "twice the size + 1", instead of "3 times the size". X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~16541^2~6 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=69f3c56296800ab0283a35a599c0bdd0e00443b4;p=xen.git fixup reallocation to "twice the size + 1", instead of "3 times the size". max *= 2 + 1 <==> max *= 3 Signed-off-by: Vincent Hanquez --- diff --git a/tools/xenstore/utils.c b/tools/xenstore/utils.c index 1bf8606b40..f8bf989c22 100644 --- a/tools/xenstore/utils.c +++ b/tools/xenstore/utils.c @@ -99,8 +99,10 @@ void *grab_file(const char *filename, unsigned long *size) *size = 0; while ((ret = read(fd, buffer + *size, max - *size)) > 0) { *size += ret; - if (*size == max) - buffer = realloc(buffer, max *= 2 + 1); + if (*size == max) { + max *= 2; + buffer = realloc(buffer, max + 1); + } } if (ret < 0) { free(buffer);