1 #define _BSD_SOURCE 2 #include <errno.h> 3 #include <stdlib.h> 4 reallocarray(void * ptr,size_t m,size_t n)5 void *reallocarray(void *ptr, size_t m, size_t n) 6 { 7 if (n && m > -1 / n) { 8 errno = ENOMEM; 9 return 0; 10 } 11 12 return realloc(ptr, m * n); 13 } 14