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

Rob Clark robdclark at gmail.com
Wed May 6 11:51:32 PDT 2015


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)


BR,
-R

> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>


More information about the mesa-dev mailing list