[Mesa-dev] [PATCH 1/4] mesa/util: add util_dynarray_clear() helper

Samuel Pitoiset samuel.pitoiset at gmail.com
Wed Jun 14 19:08:18 UTC 2017



On 06/14/2017 08:24 PM, Marek Olšák wrote:
> On Wed, Jun 14, 2017 at 1:55 PM, Samuel Pitoiset
> <samuel.pitoiset at gmail.com> wrote:
>> Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
>> ---
>>   src/util/u_dynarray.h | 6 ++++++
>>   1 file changed, 6 insertions(+)
>>
>> diff --git a/src/util/u_dynarray.h b/src/util/u_dynarray.h
>> index 57f96ff79c0..cc316323f28 100644
>> --- a/src/util/u_dynarray.h
>> +++ b/src/util/u_dynarray.h
>> @@ -68,6 +68,12 @@ util_dynarray_fini(struct util_dynarray *buf)
>>      }
>>   }
>>
>> +static inline void
>> +util_dynarray_clear(struct util_dynarray *buf)
> 
> util_dynarray_init? "clear" sounds like "free".
> 

There is already util_dynarray_init(), but it resets all fields to 0 
including 'capacity', same for util_dynarray_fini().

The idea behind util_dynarray_clear() is to avoid extra reallocations.

Though, the number of color/depth textures which need decompression is 
most likely small, so using util_dynarray_fini() shouldn't impact too 
much. What do you think?

> Marek
> 
>> +{
>> +       buf->size = 0;
>> +}
>> +
>>   #define DYN_ARRAY_INITIAL_SIZE 64
>>
>>   /* use util_dynarray_trim to reduce the allocated storage */
>> --
>> 2.13.1
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list