mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-21 09:50:36 +02:00
ralloc: remove memset from ralloc_size
only do it in rzalloc_size as it was supposed to be Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net> Tested-by: Edmondo Tommasina <edmondo.tommasina@gmail.com>
This commit is contained in:
parent
52d2b28f7f
commit
acc23b04cf
1 changed files with 11 additions and 15 deletions
|
|
@ -109,18 +109,6 @@ ralloc_context(const void *ctx)
|
||||||
|
|
||||||
void *
|
void *
|
||||||
ralloc_size(const void *ctx, size_t size)
|
ralloc_size(const void *ctx, size_t size)
|
||||||
{
|
|
||||||
/* ralloc_size was originally implemented using calloc, which meant some
|
|
||||||
* code accidentally relied on its zero filling behavior.
|
|
||||||
*
|
|
||||||
* TODO: Make ralloc_size not zero fill memory, and cleanup any code that
|
|
||||||
* should instead be using rzalloc.
|
|
||||||
*/
|
|
||||||
return rzalloc_size(ctx, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *
|
|
||||||
rzalloc_size(const void *ctx, size_t size)
|
|
||||||
{
|
{
|
||||||
void *block = malloc(size + sizeof(ralloc_header));
|
void *block = malloc(size + sizeof(ralloc_header));
|
||||||
ralloc_header *info;
|
ralloc_header *info;
|
||||||
|
|
@ -140,9 +128,6 @@ rzalloc_size(const void *ctx, size_t size)
|
||||||
info->next = NULL;
|
info->next = NULL;
|
||||||
info->destructor = NULL;
|
info->destructor = NULL;
|
||||||
|
|
||||||
/* memset the allocation except for ralloc_header */
|
|
||||||
memset(&info[1], 0, size);
|
|
||||||
|
|
||||||
parent = ctx != NULL ? get_header(ctx) : NULL;
|
parent = ctx != NULL ? get_header(ctx) : NULL;
|
||||||
|
|
||||||
add_child(parent, info);
|
add_child(parent, info);
|
||||||
|
|
@ -154,6 +139,17 @@ rzalloc_size(const void *ctx, size_t size)
|
||||||
return PTR_FROM_HEADER(info);
|
return PTR_FROM_HEADER(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
rzalloc_size(const void *ctx, size_t size)
|
||||||
|
{
|
||||||
|
void *ptr = ralloc_size(ctx, size);
|
||||||
|
|
||||||
|
if (likely(ptr))
|
||||||
|
memset(ptr, 0, size);
|
||||||
|
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
/* helper function - assumes ptr != NULL */
|
/* helper function - assumes ptr != NULL */
|
||||||
static void *
|
static void *
|
||||||
resize(void *ptr, size_t size)
|
resize(void *ptr, size_t size)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue