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) int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
{ {
void **ptrptr = ptr; void **ptrptr = ptr;
void *ret; *ptrptr = av_realloc_f(*ptrptr, nmemb, size);
if (size <= 0 || nmemb >= INT_MAX / size) if (!*ptrptr && !(nmemb && size))
return AVERROR(ENOMEM);
if (nmemb <= 0) {
av_freep(ptr);
return 0;
}
ret = av_realloc(*ptrptr, nmemb * size);
if (!ret) {
av_freep(ptr);
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
}
*ptrptr = ret;
return 0; return 0;
} }

Loading…
Cancel
Save