21 #define PNG_NO_PEDANTIC_WARNINGS 23 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) 26 #if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) 34 #ifdef PNG_USER_MEM_SUPPORTED 46 if (
type == PNG_STRUCT_INFO)
48 else if (
type == PNG_STRUCT_PNG)
53 #ifdef PNG_USER_MEM_SUPPORTED 64 if (struct_ptr !=
NULL)
73 #ifdef PNG_USER_MEM_SUPPORTED 83 if (struct_ptr !=
NULL)
85 #ifdef PNG_USER_MEM_SUPPORTED 91 (*(
free_fn))(png_ptr, struct_ptr);
134 if (png_ptr ==
NULL || size == 0)
137 #ifdef PNG_USER_MEM_SUPPORTED 138 if (png_ptr->malloc_fn !=
NULL)
142 if (ret ==
NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
153 if (png_ptr ==
NULL || size == 0)
156 #ifdef PNG_MAX_MALLOC_64K 165 if (size != (
size_t)size)
169 if (png_ptr->offset_table ==
NULL)
172 ret = farmalloc(size);
187 if (png_ptr->zlib_window_bits > 14)
188 num_blocks = (
int)(1 << (png_ptr->zlib_window_bits - 14));
191 if (png_ptr->zlib_mem_level >= 7)
192 num_blocks += (
int)(1 << (png_ptr->zlib_mem_level - 7));
198 table = farmalloc(total_size);
202 #ifndef PNG_USER_MEM_SUPPORTED 203 if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
213 #ifndef PNG_USER_MEM_SUPPORTED 214 if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
216 "Farmalloc didn't return normalized pointer");
219 "Farmalloc didn't return normalized pointer");
224 png_ptr->offset_table =
table;
225 png_ptr->offset_table_ptr = farmalloc(num_blocks *
228 if (png_ptr->offset_table_ptr ==
NULL)
230 #ifndef PNG_USER_MEM_SUPPORTED 231 if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
242 hptr = (
png_byte huge *)((
long)(hptr) & 0xfffffff0L);
247 png_ptr->offset_table_ptr[
i] = (
png_bytep)hptr;
252 png_ptr->offset_table_count = 0;
253 png_ptr->offset_table_count_free = 0;
257 if (png_ptr->offset_table_count >= png_ptr->offset_table_number)
259 #ifndef PNG_USER_MEM_SUPPORTED 260 if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
268 ret = png_ptr->offset_table_ptr[png_ptr->offset_table_count++];
271 ret = farmalloc(size);
273 #ifndef PNG_USER_MEM_SUPPORTED 276 if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
296 #ifdef PNG_USER_MEM_SUPPORTED 297 if (png_ptr->free_fn !=
NULL)
299 (*(png_ptr->free_fn))(png_ptr,
ptr);
314 if (png_ptr->offset_table !=
NULL)
318 for (i = 0; i < png_ptr->offset_table_count; i++)
320 if (ptr == png_ptr->offset_table_ptr[i])
323 png_ptr->offset_table_count_free++;
327 if (png_ptr->offset_table_count_free == png_ptr->offset_table_count)
329 farfree(png_ptr->offset_table);
330 farfree(png_ptr->offset_table_ptr);
331 png_ptr->offset_table =
NULL;
332 png_ptr->offset_table_ptr =
NULL;
350 #ifdef PNG_USER_MEM_SUPPORTED 364 if (type == PNG_STRUCT_INFO)
366 else if (type == PNG_STRUCT_PNG)
371 #ifdef PNG_USER_MEM_SUPPORTED 372 if (malloc_fn !=
NULL)
378 if (struct_ptr !=
NULL)
384 #if defined(__TURBOC__) && !defined(__FLAT__) 387 # if defined(_MSC_VER) && defined(MAXSEG_64K) 393 if (struct_ptr !=
NULL)
404 #ifdef PNG_USER_MEM_SUPPORTED 414 if (struct_ptr !=
NULL)
416 #ifdef PNG_USER_MEM_SUPPORTED 422 (*(
free_fn))(png_ptr, struct_ptr);
426 #if defined(__TURBOC__) && !defined(__FLAT__) 429 # if defined(_MSC_VER) && defined(MAXSEG_64K) 461 #ifdef PNG_USER_MEM_SUPPORTED 462 if (png_ptr ==
NULL || size == 0)
465 if (png_ptr->malloc_fn !=
NULL)
469 if (ret ==
NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
480 if (png_ptr ==
NULL || size == 0)
483 #ifdef PNG_MAX_MALLOC_64K 486 #ifndef PNG_USER_MEM_SUPPORTED 487 if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
488 png_error(png_ptr,
"Cannot Allocate > 64K");
496 #if defined(__TURBOC__) && !defined(__FLAT__) 497 if (size != (
unsigned long)size)
500 ret = farmalloc(size);
502 # if defined(_MSC_VER) && defined(MAXSEG_64K) 503 if (size != (
unsigned long)size)
506 ret = halloc(size, 1);
508 if (size != (
size_t)size)
511 ret =
malloc((
size_t)size);
515 #ifndef PNG_USER_MEM_SUPPORTED 516 if (ret ==
NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
532 #ifdef PNG_USER_MEM_SUPPORTED 533 if (png_ptr->free_fn !=
NULL)
535 (*(png_ptr->free_fn))(png_ptr,
ptr);
549 #if defined(__TURBOC__) && !defined(__FLAT__) 552 # if defined(_MSC_VER) && defined(MAXSEG_64K) 563 # define png_malloc_warn png_malloc 578 save_flags = png_ptr->flags;
579 png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK;
581 png_ptr->flags=save_flags;
594 png_error(png_ptr,
"Overflow in png_memcpy_check.");
607 png_error(png_ptr,
"Overflow in png_memset_check.");
613 #ifdef PNG_USER_MEM_SUPPORTED GLenum GLuint GLenum GLsizei length
png_voidp png_error_ptr png_error_ptr png_voidp png_malloc_ptr malloc_fn
png_voidp png_create_struct(int type)
png_voidp png_calloc(png_structp png_ptr, png_uint_32 size)
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
png_struct FAR * png_structp
#define png_error(s1, s2)
JBLOCKROW JDIMENSION num_blocks
void png_destroy_struct(png_voidp struct_ptr)
void PNGAPI png_warning(png_structp png_ptr, png_const_charp warning_message)
GLsizei const GLfloat * value
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)
GLenum GLsizei GLenum GLenum const GLvoid * table
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)