[Mesa-dev] [PATCH] util: Take memset out of rzalloc_size()

Juha-Pekka Heikkila juhapekka.heikkila at gmail.com
Thu May 7 02:30:11 PDT 2015


On 06.05.2015 21:51, Rob Clark wrote:
> On Wed, May 6, 2015 at 1:24 PM, Kenneth Graunke <kenneth at whitecape.org> wrote:
>> On Wednesday, May 06, 2015 03:35:27 PM Juha-Pekka Heikkila wrote:
>>> rzalloc_size() call ralloc_size() to allocate memory. ralloc_size()
>>> use calloc to get memory thus zeroing in rzalloc_size is not
>>> necessary.
>>>
>>> Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
>>> ---
>>>  src/util/ralloc.c | 2 --
>>>  1 file changed, 2 deletions(-)
>>>
>>> diff --git a/src/util/ralloc.c b/src/util/ralloc.c
>>> index 01719c8..09f5fcd 100644
>>> --- a/src/util/ralloc.c
>>> +++ b/src/util/ralloc.c
>>> @@ -132,8 +132,6 @@ void *
>>>  rzalloc_size(const void *ctx, size_t size)
>>>  {
>>>     void *ptr = ralloc_size(ctx, size);
>>> -   if (likely(ptr != NULL))
>>> -      memset(ptr, 0, size);
>>>     return ptr;
>>>  }
>>>
>>>
>>
>> Wow, I have no idea why I did that.  This is certainly
>> counter-intuitive.
>>
>> rzalloc() is supposed to guarantee zeroed memory.  ralloc() is not, but
>> it looks like it always has for some reason.  I'm somewhat inclined to
>> change ralloc_size() to use malloc instead of calloc.
>>
>> I wonder how many things would break :)
>>
> 
> try the change conditionally ifndef DEBUG??  (abusing --enable-debug
> as a proxy for --im-actually-a-mesa-dev-and-want-to-see-the-crashes)
> 
> 

I did have a try to put malloc in place of calloc and did see basically
almost all Piglit tests starting to fail on this one. There were handful
of tests which still worked but also saw many different places for
crashes thus though at first suggest just taking the memset out. :)

/Juha-Pekka


More information about the mesa-dev mailing list