[PATCH v2] tests: use xmalloc to allocate implementation array

Siddhesh Poyarekar siddhesh@sourceware.org
Wed Jul 28 08:03:00 GMT 2021


On 7/28/21 1:28 PM, Florian Weimer wrote:
> * Siddhesh Poyarekar:
> 
>> The benchmark and tests must fail in case of allocation failure in the
>> implementation array.  Also annotate the x* allocators in support.h so
>> that the compiler has more information about them.
>> ---
>>   benchtests/bench-string.h |  5 +++--
>>   string/test-string.h      |  5 +++--
>>   support/support.h         | 24 +++++++++++++++++-------
>>   3 files changed, 23 insertions(+), 11 deletions(-)
>>
>> diff --git a/benchtests/bench-string.h b/benchtests/bench-string.h
>> index fd25264417..12f27473ff 100644
>> --- a/benchtests/bench-string.h
>> +++ b/benchtests/bench-string.h
>> @@ -18,6 +18,7 @@
>>   
>>   #include <getopt.h>
>>   #include <sys/cdefs.h>
>> +#include <programs/xmalloc.h>
>>   
>>   /* We are compiled under _ISOMAC, so libc-symbols.h does not do this
>>      for us.  */
>> @@ -200,8 +201,8 @@ static impl_t *impl_array;
>>   		 skip = impl;						      \
>>   	       else							      \
>>   		 impl_count++;						      \
>> -	     a = impl_array = malloc ((impl_count + func_count) *	      \
>> -				   sizeof (impl_t));			      \
>> +	     a = impl_array = xmalloc ((impl_count + func_count) *	      \
>> +				       sizeof (impl_t));		      \
>>   	     for (impl = __start_impls; impl < __stop_impls; ++impl)	      \
>>   	       if (impl != skip)					      \
>>   		 *a++ = *impl;						      \
> 
> Okay if it actually links.
> 

It does because it uses the xmalloc in libsupport.  I'll wean the 
benchmarks away from libsupport in 2.35.

Siddhesh


More information about the Libc-alpha mailing list