133 if (add_elements <= 0 || element_size == 0 || old_elements < 0 ||
134 (old_array == NULL && old_elements > 0))
135 png_error(png_ptr,
"internal error: array realloc");
140 if (add_elements <= INT_MAX - old_elements)
143 old_elements+add_elements, element_size);
145 if (new_array != NULL)
150 if (old_elements > 0)
151 memcpy(new_array, old_array, element_size*(
unsigned)old_elements);
153 memset((
char*)new_array + element_size*(
unsigned)old_elements, 0,
154 element_size*(
unsigned)add_elements);
static png_voidp png_malloc_array_checked(png_const_structrp png_ptr, int nelements, size_t element_size)
Definition: pngmem.c:106
void * png_voidp
Definition: pngconf.h:598
PNG_IMPEXP void() png_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:40