diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2020-01-22 02:49:53 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2020-01-22 02:49:53 +0000 |
commit | d264279e28002d81821c883795911844a4c01a2c (patch) | |
tree | b0481616eda55b543a0dc1487d096c3239885c41 /lib/mesa/src/util/ralloc.c | |
parent | fdcc03929065b5bf5dd93553db219ea3e05c8c34 (diff) |
Merge Mesa 19.2.8
Diffstat (limited to 'lib/mesa/src/util/ralloc.c')
-rw-r--r-- | lib/mesa/src/util/ralloc.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/mesa/src/util/ralloc.c b/lib/mesa/src/util/ralloc.c index fc3566199..0d20223d9 100644 --- a/lib/mesa/src/util/ralloc.c +++ b/lib/mesa/src/util/ralloc.c @@ -198,6 +198,21 @@ reralloc_size(const void *ctx, void *ptr, size_t size) } void * +rerzalloc_size(const void *ctx, void *ptr, size_t old_size, size_t new_size) +{ + if (unlikely(ptr == NULL)) + return rzalloc_size(ctx, new_size); + + assert(ralloc_parent(ptr) == ctx); + ptr = resize(ptr, new_size); + + if (new_size > old_size) + memset((char *)ptr + old_size, 0, new_size - old_size); + + return ptr; +} + +void * ralloc_array_size(const void *ctx, size_t size, unsigned count) { if (count > SIZE_MAX/size) @@ -224,6 +239,16 @@ reralloc_array_size(const void *ctx, void *ptr, size_t size, unsigned count) return reralloc_size(ctx, ptr, size * count); } +void * +rerzalloc_array_size(const void *ctx, void *ptr, size_t size, + unsigned old_count, unsigned new_count) +{ + if (new_count > SIZE_MAX/size) + return NULL; + + return rerzalloc_size(ctx, ptr, size * old_count, size * new_count); +} + void ralloc_free(void *ptr) { |