| 100 | |
| 101 | #if !HAVE_DECL_REALLOCARRAY |
| 102 | static inline void * |
| 103 | static_reallocarray (void *ptr, size_t nmemb, size_t size) |
| 104 | { |
| 105 | if (size > 0 && nmemb > SIZE_MAX / size) |
| 106 | { |
| 107 | errno = ENOMEM; |
| 108 | return NULL; |
| 109 | } |
| 110 | return realloc (ptr, nmemb * size); |
| 111 | } |
| 112 | #undef reallocarray |
| 113 | #define reallocarray(ptr, nmemb, size) \ |
| 114 | static_reallocarray((ptr), (nmemb), (size)) |