diff options
author | vhanquez@kneesa.uk.xensource.com <vhanquez@kneesa.uk.xensource.com> | 2006-01-24 10:52:52 +0000 |
---|---|---|
committer | vhanquez@kneesa.uk.xensource.com <vhanquez@kneesa.uk.xensource.com> | 2006-01-24 10:52:52 +0000 |
commit | 69f3c56296800ab0283a35a599c0bdd0e00443b4 (patch) | |
tree | 7accac8b7198f2cdbf7bf2b2e2b51f712d16aade /tools/xenstore/utils.c | |
parent | 6ab3d2a42109645b5b3fccc8838afa0fcf9ff4dd (diff) | |
download | xen-69f3c56296800ab0283a35a599c0bdd0e00443b4.tar.gz xen-69f3c56296800ab0283a35a599c0bdd0e00443b4.tar.bz2 xen-69f3c56296800ab0283a35a599c0bdd0e00443b4.zip |
fixup reallocation to "twice the size + 1", instead of "3 times the size".
max *= 2 + 1 <==> max *= 3
Signed-off-by: Vincent Hanquez <vincent@xensource.com>
Diffstat (limited to 'tools/xenstore/utils.c')
-rw-r--r-- | tools/xenstore/utils.c | 6 |
1 files changed, 4 insertions, 2 deletions
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); |