19 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) 22 #if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) 30 #ifdef PNG_USER_MEM_SUPPORTED 42 if (
type == PNG_STRUCT_INFO)
44 else if (
type == PNG_STRUCT_PNG)
49 #ifdef PNG_USER_MEM_SUPPORTED 60 if (struct_ptr != NULL)
69 #ifdef PNG_USER_MEM_SUPPORTED 79 if (struct_ptr != NULL)
81 #ifdef PNG_USER_MEM_SUPPORTED 87 (*(
free_fn))(png_ptr, struct_ptr);
120 if (png_ptr == NULL || size == 0)
123 #ifdef PNG_USER_MEM_SUPPORTED 124 if (png_ptr->malloc_fn != NULL)
128 if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
139 if (png_ptr == NULL || size == 0)
142 #ifdef PNG_MAX_MALLOC_64K 151 if (size != (
size_t)size)
155 if (png_ptr->offset_table == NULL)
158 ret = farmalloc(size);
159 if (ret == NULL || ((
png_size_t)ret & 0xffff))
173 if (png_ptr->zlib_window_bits > 14)
174 num_blocks = (
int)(1 << (png_ptr->zlib_window_bits - 14));
177 if (png_ptr->zlib_mem_level >= 7)
178 num_blocks += (
int)(1 << (png_ptr->zlib_mem_level - 7));
184 table = farmalloc(total_size);
188 #ifndef PNG_USER_MEM_SUPPORTED 189 if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
199 #ifndef PNG_USER_MEM_SUPPORTED 200 if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
202 "Farmalloc didn't return normalized pointer");
205 "Farmalloc didn't return normalized pointer");
210 png_ptr->offset_table = table;
211 png_ptr->offset_table_ptr = farmalloc(num_blocks *
214 if (png_ptr->offset_table_ptr == NULL)
216 #ifndef PNG_USER_MEM_SUPPORTED 217 if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
228 hptr = (
png_byte huge *)((
long)(hptr) & 0xfffffff0L);
233 png_ptr->offset_table_ptr[
i] = (
png_bytep)hptr;
238 png_ptr->offset_table_count = 0;
239 png_ptr->offset_table_count_free = 0;
243 if (png_ptr->offset_table_count >= png_ptr->offset_table_number)
245 #ifndef PNG_USER_MEM_SUPPORTED 246 if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
254 ret = png_ptr->offset_table_ptr[png_ptr->offset_table_count++];
257 ret = farmalloc(size);
259 #ifndef PNG_USER_MEM_SUPPORTED 262 if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
279 if (png_ptr == NULL || ptr == NULL)
282 #ifdef PNG_USER_MEM_SUPPORTED 283 if (png_ptr->free_fn != NULL)
285 (*(png_ptr->free_fn))(png_ptr,
ptr);
296 if (png_ptr == NULL || ptr == NULL)
return;
298 if (png_ptr->offset_table != NULL)
302 for (i = 0; i < png_ptr->offset_table_count; i++)
304 if (ptr == png_ptr->offset_table_ptr[i])
307 png_ptr->offset_table_count_free++;
311 if (png_ptr->offset_table_count_free == png_ptr->offset_table_count)
313 farfree(png_ptr->offset_table);
314 farfree(png_ptr->offset_table_ptr);
315 png_ptr->offset_table = NULL;
316 png_ptr->offset_table_ptr = NULL;
334 #ifdef PNG_USER_MEM_SUPPORTED 348 if (type == PNG_STRUCT_INFO)
350 else if (type == PNG_STRUCT_PNG)
355 #ifdef PNG_USER_MEM_SUPPORTED 356 if (malloc_fn != NULL)
362 if (struct_ptr != NULL)
368 #if defined(__TURBOC__) && !defined(__FLAT__) 371 # if defined(_MSC_VER) && defined(MAXSEG_64K) 377 if (struct_ptr != NULL)
388 #ifdef PNG_USER_MEM_SUPPORTED 398 if (struct_ptr != NULL)
400 #ifdef PNG_USER_MEM_SUPPORTED 406 (*(
free_fn))(png_ptr, struct_ptr);
410 #if defined(__TURBOC__) && !defined(__FLAT__) 413 # if defined(_MSC_VER) && defined(MAXSEG_64K) 433 #ifdef PNG_USER_MEM_SUPPORTED 434 if (png_ptr == NULL || size == 0)
437 if (png_ptr->malloc_fn != NULL)
441 if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
452 if (png_ptr == NULL || size == 0)
455 #ifdef PNG_MAX_MALLOC_64K 458 #ifndef PNG_USER_MEM_SUPPORTED 459 if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
460 png_error(png_ptr,
"Cannot Allocate > 64K");
468 #if defined(__TURBOC__) && !defined(__FLAT__) 469 if (size != (
unsigned long)size)
472 ret = farmalloc(size);
474 # if defined(_MSC_VER) && defined(MAXSEG_64K) 475 if (size != (
unsigned long)size)
478 ret = halloc(size, 1);
480 if (size != (
size_t)size)
483 ret =
malloc((
size_t)size);
487 #ifndef PNG_USER_MEM_SUPPORTED 488 if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
500 if (png_ptr == NULL || ptr == NULL)
503 #ifdef PNG_USER_MEM_SUPPORTED 504 if (png_ptr->free_fn != NULL)
506 (*(png_ptr->free_fn))(png_ptr,
ptr);
514 if (png_ptr == NULL || ptr == NULL)
519 #if defined(__TURBOC__) && !defined(__FLAT__) 522 # if defined(_MSC_VER) && defined(MAXSEG_64K) 532 #if defined(PNG_1_0_X) 533 # define png_malloc_warn png_malloc 545 if (png_ptr == NULL)
return (NULL);
547 save_flags = png_ptr->flags;
548 png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK;
550 png_ptr->flags=save_flags;
563 png_error(png_ptr,
"Overflow in png_memcpy_check.");
576 png_error(png_ptr,
"Overflow in png_memset_check.");
582 #ifdef PNG_USER_MEM_SUPPORTED 605 if (png_ptr == NULL)
return (NULL);
png_voidp png_error_ptr png_error_ptr png_voidp png_malloc_ptr malloc_fn
png_voidp png_create_struct(int type)
png_infop png_charp png_int_32 png_int_32 int * type
png_voidp png_error_ptr png_error_ptr png_voidp png_malloc_ptr png_free_ptr free_fn
void PNGAPI png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)
#define png_malloc_ptr_NULL
RTC::ReturnCode_t ret(RTC::Local::ReturnCode_t r)
png_bytep png_bytep png_size_t length
png_struct FAR * png_structp
JBLOCKROW JDIMENSION num_blocks
void PNGAPI png_error(png_structp png_ptr, png_const_charp error_message)
void png_destroy_struct(png_voidp struct_ptr)
void PNGAPI png_warning(png_structp png_ptr, png_const_charp warning_message)
png_voidp PNGAPI png_malloc_default(png_structp png_ptr, png_uint_32 size)
png_voidp PNGAPI png_get_mem_ptr(png_structp png_ptr)
png_voidp png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr)
#define png_free_ptr_NULL
void PNGAPI png_free_default(png_structp png_ptr, png_voidp ptr)
png_voidp PNGAPI png_memcpy_check(png_structp png_ptr, png_voidp s1, png_voidp s2, png_uint_32 length)
void png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, png_voidp mem_ptr)
png_voidp PNGAPI png_memset_check(png_structp png_ptr, png_voidp s1, int value, png_uint_32 length)
unsigned long png_uint_32
png_charp PNGAPI png_get_copyright(png_structp png_ptr)
png_voidp png_error_ptr png_error_ptr png_voidp mem_ptr
void PNGAPI png_free(png_structp png_ptr, png_voidp ptr)
png_voidp PNGAPI png_malloc(png_structp png_ptr, png_uint_32 size)
png_voidp PNGAPI png_malloc_warn(png_structp png_ptr, png_uint_32 size)