[PATCH] Add reallocarray function.

Florian Weimer fweimer@redhat.com
Tue Apr 11 07:55:00 GMT 2017


On 04/10/2017 05:00 PM, Dennis Wölfing wrote:
> +void *
> +__libc_reallocarray(void *optr, size_t nmemb, size_t elem_size)
> +{
> +  INTERNAL_SIZE_T bytes;
> +  if (check_mul_overflow(nmemb, elem_size, &bytes))
> +    {
> +      __set_errno (ENOMEM);
> +      return 0;
> +    }
> +  else
> +    return __libc_realloc (optr, bytes);
> +}

This needs to go into its own file and has to call realloc (not 
__libc_realloc), otherwise it will not be compatible with malloc 
interposition.

Thanks,
Florian



More information about the Libc-alpha mailing list