[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] fixup reallocation to "twice the size + 1", instead of "3 times the size".



# HG changeset patch
# User vhanquez@xxxxxxxxxxxxxxxxxxxxxxx
# Node ID b89b94c71b2fd1e756b33189040d838af388713b
# Parent  df36ac1ddcbfee1c05e8e264c905e1be553d0cf9
fixup reallocation to "twice the size + 1", instead of "3 times the size".
max *= 2 + 1 <==> max *= 3

Signed-off-by: Vincent Hanquez <vincent@xxxxxxxxxxxxx>

diff -r df36ac1ddcbf -r b89b94c71b2f tools/xenstore/utils.c
--- a/tools/xenstore/utils.c    Tue Jan 24 10:37:44 2006
+++ b/tools/xenstore/utils.c    Tue Jan 24 10:52:52 2006
@@ -99,8 +99,10 @@
        *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);

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.