22#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
34 png_free(&dummy_struct,
png_ptr);
36# ifdef PNG_SETJMP_SUPPORTED
38 png_free_jmpbuf(&dummy_struct);
76#ifndef PNG_USER_MEM_SUPPORTED
84# ifdef PNG_MAX_MALLOC_64K
89#ifdef PNG_USER_MEM_SUPPORTED
102#if defined(PNG_TEXT_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) ||\
103 defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED)
115 return png_malloc_base(
png_ptr, req * element_size);
125 if (nelements <= 0 || element_size == 0)
126 png_error(
png_ptr,
"internal error: array alloc");
128 return png_malloc_array_checked(
png_ptr, nelements, element_size);
133 int old_elements,
int add_elements,
size_t element_size),
PNG_ALLOCATED)
136 if (add_elements <= 0 || element_size == 0 || old_elements < 0 ||
137 (old_array ==
NULL && old_elements > 0))
138 png_error(
png_ptr,
"internal error: array realloc");
143 if (add_elements <=
INT_MAX - old_elements)
146 old_elements+add_elements, element_size);
148 if (new_array !=
NULL)
153 if (old_elements > 0)
154 memcpy(new_array, old_array, element_size*(
unsigned)old_elements);
156 memset((
char*)new_array + element_size*(
unsigned)old_elements, 0,
157 element_size*(
unsigned)add_elements);
182 png_error(
png_ptr,
"Out of memory");
187#ifdef PNG_USER_MEM_SUPPORTED
201 png_error(
png_ptr,
"Out of Memory");
222 png_warning(
png_ptr,
"Out of memory");
237#ifdef PNG_USER_MEM_SUPPORTED
255#ifdef PNG_USER_MEM_SUPPORTED
261 malloc_fn, png_free_ptr free_fn)
266 png_ptr->malloc_fn = malloc_fn;
#define memcpy(s1, s2, n)
const png_struct *PNG_RESTRICT png_const_structrp
png_struct *PNG_RESTRICT png_structrp
#define PNG_FUNCTION(type, name, args, attributes)
#define PNG_UNUSED(param)
#define png_constcast(type, value)