diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/auxiliary/util/u_dynarray.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/gallium/auxiliary/util/u_dynarray.h b/src/gallium/auxiliary/util/u_dynarray.h index 94a882b59ee..5d124832be3 100644 --- a/src/gallium/auxiliary/util/u_dynarray.h +++ b/src/gallium/auxiliary/util/u_dynarray.h @@ -81,8 +81,14 @@ util_dynarray_grow(struct util_dynarray *buf, int size) static INLINE void util_dynarray_trim(struct util_dynarray *buf) { - buf->data = REALLOC(buf->data, buf->capacity, buf->size); - buf->capacity = buf->size; + if(buf->size) { + buf->data = REALLOC(buf->data, buf->capacity, buf->size); + buf->capacity = buf->size; + } else { + FREE(buf->data); + buf->data = 0; + buf->capacity = 0; + } } #define util_dynarray_append(buf, type, v) do {type __v = (v); memcpy(util_dynarray_grow((buf), sizeof(type)), &__v, sizeof(type));} while(0) |