ia64/xen-unstable

changeset 8639:b89b94c71b2f

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>
author vhanquez@kneesa.uk.xensource.com
date Tue Jan 24 10:52:52 2006 +0000 (2006-01-24)
parents df36ac1ddcbf
children 45f3b9cfbd83
files tools/xenstore/utils.c
line diff
     1.1 --- a/tools/xenstore/utils.c	Tue Jan 24 10:37:44 2006 +0000
     1.2 +++ b/tools/xenstore/utils.c	Tue Jan 24 10:52:52 2006 +0000
     1.3 @@ -99,8 +99,10 @@ void *grab_file(const char *filename, un
     1.4  	*size = 0;
     1.5  	while ((ret = read(fd, buffer + *size, max - *size)) > 0) {
     1.6  		*size += ret;
     1.7 -		if (*size == max)
     1.8 -			buffer = realloc(buffer, max *= 2 + 1);
     1.9 +		if (*size == max) {
    1.10 +			max *= 2;
    1.11 +			buffer = realloc(buffer, max + 1);
    1.12 +		}
    1.13  	}
    1.14  	if (ret < 0) {
    1.15  		free(buffer);