WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

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

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] fixup reallocation to "twice the size + 1", instead of "3 times the size".
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 24 Jan 2006 15:22:07 +0000
Delivery-date: Tue, 24 Jan 2006 15:31:24 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# 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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] fixup reallocation to "twice the size + 1", instead of "3 times the size"., Xen patchbot -unstable <=