gallium/auxiliary: add util_dynarray_resize
authorLuca Barbieri <luca@luca-barbieri.com>
Tue, 13 Apr 2010 06:23:29 +0000 (08:23 +0200)
committerLuca Barbieri <luca@luca-barbieri.com>
Tue, 13 Apr 2010 06:25:39 +0000 (08:25 +0200)
src/gallium/auxiliary/util/u_dynarray.h

index 5d124832be34fc18279f2647e9ef2393503fef36..d16d8bf4f3cc8b2258ad106de8770a9bed665715 100644 (file)
@@ -59,10 +59,10 @@ util_dynarray_fini(struct util_dynarray *buf)
    }
 }
 
+/* use util_dynarray_trim to reduce the allocated storage */
 static INLINE void *
-util_dynarray_grow(struct util_dynarray *buf, int size)
+util_dynarray_resize(struct util_dynarray *buf, unsigned newsize)
 {
-   unsigned newsize = buf->size + size;
    char *p;
    if(newsize > buf->capacity)
    {
@@ -78,6 +78,12 @@ util_dynarray_grow(struct util_dynarray *buf, int size)
    return p;
 }
 
+static INLINE void *
+util_dynarray_grow(struct util_dynarray *buf, int diff)
+{
+   return util_dynarray_resize(buf, buf->size + diff);
+}
+
 static INLINE void
 util_dynarray_trim(struct util_dynarray *buf)
 {