Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cosmetics/tiny computation saving
authorMartin Quinson <martin.quinson@loria.fr>
Fri, 28 Oct 2011 14:05:34 +0000 (16:05 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Fri, 28 Oct 2011 14:05:34 +0000 (16:05 +0200)
src/xbt/xbt_strbuff.c

index a474b3a..4af8992 100644 (file)
@@ -78,9 +78,8 @@ void xbt_strbuff_append(xbt_strbuff_t b, const char *toadd)
   needed_space = b->used + addlen + 1;
 
   if (needed_space > b->size) {
   needed_space = b->used + addlen + 1;
 
   if (needed_space > b->size) {
-    b->data =
-        realloc(b->data, MAX(minimal_increment + b->used, needed_space));
     b->size = MAX(minimal_increment + b->used, needed_space);
     b->size = MAX(minimal_increment + b->used, needed_space);
+    b->data = realloc(b->data, b->size);
   }
   strcpy(b->data + b->used, toadd);
   b->used += addlen;
   }
   strcpy(b->data + b->used, toadd);
   b->used += addlen;