avutil/mem: simplify av_reallocp_array() by using av_realloc_f()

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
pull/25/head
Michael Niedermayer 12 years ago
parent 21bf0d6f80
commit fbc472da29
  1. 14
      libavutil/mem.c

@ -190,19 +190,9 @@ void *av_realloc_array(void *ptr, size_t nmemb, size_t size)
int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
{
void **ptrptr = ptr;
void *ret;
if (size <= 0 || nmemb >= INT_MAX / size)
return AVERROR(ENOMEM);
if (nmemb <= 0) {
av_freep(ptr);
return 0;
}
ret = av_realloc(*ptrptr, nmemb * size);
if (!ret) {
av_freep(ptr);
*ptrptr = av_realloc_f(*ptrptr, nmemb, size);
if (!*ptrptr && !(nmemb && size))
return AVERROR(ENOMEM);
}
*ptrptr = ret;
return 0;
}

Loading…
Cancel
Save