Lose ensure* stuff.

This commit is contained in:
Nicholas Marriott
2008-08-07 20:20:52 +00:00
parent 65833c2976
commit de0e1c6284
6 changed files with 47 additions and 96 deletions

View File

@ -1,4 +1,4 @@
/* $Id: buffer.c,v 1.4 2007-12-06 09:46:21 nicm Exp $ */
/* $Id: buffer.c,v 1.5 2008-08-07 20:20:52 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -71,7 +71,12 @@ buffer_ensure(struct buffer *b, size_t size)
b->off = 0;
}
ENSURE_FOR(b->base, b->space, b->size, size);
if (SIZE_MAX - b->size < size)
fatalx("size too big");
while (b->space < b->size + size) {
b->base = xrealloc(b->base, 2, b->space);
b->space *= 2;
}
}
/* Adjust buffer after data appended. */