diff options
Diffstat (limited to 'src/3rdparty/libpng/pngmem.c')
-rw-r--r-- | src/3rdparty/libpng/pngmem.c | 95 |
1 files changed, 43 insertions, 52 deletions
diff --git a/src/3rdparty/libpng/pngmem.c b/src/3rdparty/libpng/pngmem.c index e190cc3..dee2966 100644 --- a/src/3rdparty/libpng/pngmem.c +++ b/src/3rdparty/libpng/pngmem.c @@ -1,8 +1,8 @@ /* pngmem.c - stub functions for memory allocation * - * Last changed in libpng 1.2.37 [June 4, 2009] - * Copyright (c) 1998-2009 Glenn Randers-Pehrson + * Last changed in libpng 1.4.0 [January 3, 2010] + * Copyright (c) 1998-2010 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -17,9 +17,10 @@ * identify the replacement functions. */ -#define PNG_INTERNAL +#define PNG_NO_PEDANTIC_WARNINGS #include "png.h" #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) +#include "pngpriv.h" /* Borland DOS special memory handler */ #if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) @@ -31,7 +32,7 @@ png_voidp /* PRIVATE */ png_create_struct(int type) { #ifdef PNG_USER_MEM_SUPPORTED - return (png_create_struct_2(type, png_malloc_ptr_NULL, png_voidp_NULL)); + return (png_create_struct_2(type, NULL, NULL)); } /* Alternate version of png_create_struct, for use with user-defined malloc. */ @@ -70,7 +71,7 @@ void /* PRIVATE */ png_destroy_struct(png_voidp struct_ptr) { #ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2(struct_ptr, png_free_ptr_NULL, png_voidp_NULL); + png_destroy_struct_2(struct_ptr, NULL, NULL); } /* Free memory allocated by a png_create_struct() call */ @@ -114,9 +115,19 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, * result, we would be truncating potentially larger memory requests * (which should cause a fatal error) and introducing major problems. */ +png_voidp PNGAPI +png_calloc(png_structp png_ptr, png_alloc_size_t size) +{ + png_voidp ret; + + ret = (png_malloc(png_ptr, size)); + if (ret != NULL) + png_memset(ret,0,(png_size_t)size); + return (ret); +} png_voidp PNGAPI -png_malloc(png_structp png_ptr, png_uint_32 size) +png_malloc(png_structp png_ptr, png_alloc_size_t size) { png_voidp ret; @@ -129,12 +140,12 @@ png_malloc(png_structp png_ptr, png_uint_32 size) else ret = (png_malloc_default(png_ptr, size)); if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out of memory!"); + png_error(png_ptr, "Out of memory"); return (ret); } png_voidp PNGAPI -png_malloc_default(png_structp png_ptr, png_uint_32 size) +png_malloc_default(png_structp png_ptr, png_alloc_size_t size) { png_voidp ret; #endif /* PNG_USER_MEM_SUPPORTED */ @@ -190,9 +201,9 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size) { #ifndef PNG_USER_MEM_SUPPORTED if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out Of Memory."); /* Note "O" and "M" */ + png_error(png_ptr, "Out Of Memory"); /* Note "O" and "M" */ else - png_warning(png_ptr, "Out Of Memory."); + png_warning(png_ptr, "Out Of Memory"); #endif return (NULL); } @@ -218,9 +229,9 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size) { #ifndef PNG_USER_MEM_SUPPORTED if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out Of memory."); /* Note "O" and "M" */ + png_error(png_ptr, "Out Of memory"); /* Note "O" and "M" */ else - png_warning(png_ptr, "Out Of memory."); + png_warning(png_ptr, "Out Of memory"); #endif return (NULL); } @@ -247,9 +258,9 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size) { #ifndef PNG_USER_MEM_SUPPORTED if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out of Memory."); /* Note "o" and "M" */ + png_error(png_ptr, "Out of Memory"); /* Note "o" and "M" */ else - png_warning(png_ptr, "Out of Memory."); + png_warning(png_ptr, "Out of Memory"); #endif return (NULL); } @@ -263,9 +274,9 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size) if (ret == NULL) { if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out of memory."); /* Note "o" and "m" */ + png_error(png_ptr, "Out of memory"); /* Note "o" and "m" */ else - png_warning(png_ptr, "Out of memory."); /* Note "o" and "m" */ + png_warning(png_ptr, "Out of memory"); /* Note "o" and "m" */ } #endif @@ -337,7 +348,7 @@ png_voidp /* PRIVATE */ png_create_struct(int type) { #ifdef PNG_USER_MEM_SUPPORTED - return (png_create_struct_2(type, png_malloc_ptr_NULL, png_voidp_NULL)); + return (png_create_struct_2(type, NULL, NULL)); } /* Allocate memory for a png_struct or a png_info. The malloc and @@ -391,7 +402,7 @@ void /* PRIVATE */ png_destroy_struct(png_voidp struct_ptr) { #ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2(struct_ptr, png_free_ptr_NULL, png_voidp_NULL); + png_destroy_struct_2(struct_ptr, NULL, NULL); } /* Free memory allocated by a png_create_struct() call */ @@ -431,9 +442,19 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, * have the ability to do that. */ +png_voidp PNGAPI +png_calloc(png_structp png_ptr, png_alloc_size_t size) +{ + png_voidp ret; + + ret = (png_malloc(png_ptr, size)); + if (ret != NULL) + png_memset(ret,0,(png_size_t)size); + return (ret); +} png_voidp PNGAPI -png_malloc(png_structp png_ptr, png_uint_32 size) +png_malloc(png_structp png_ptr, png_alloc_size_t size) { png_voidp ret; @@ -446,12 +467,12 @@ png_malloc(png_structp png_ptr, png_uint_32 size) else ret = (png_malloc_default(png_ptr, size)); if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out of Memory!"); + png_error(png_ptr, "Out of Memory"); return (ret); } png_voidp PNGAPI -png_malloc_default(png_structp png_ptr, png_uint_32 size) +png_malloc_default(png_structp png_ptr, png_alloc_size_t size) { png_voidp ret; #endif /* PNG_USER_MEM_SUPPORTED */ @@ -538,16 +559,13 @@ png_free_default(png_structp png_ptr, png_voidp ptr) #endif /* Not Borland DOS special memory handler */ -#if defined(PNG_1_0_X) -# define png_malloc_warn png_malloc -#else /* This function was added at libpng version 1.2.3. The png_malloc_warn() * function will set up png_malloc() to issue a png_warning and return NULL * instead of issuing a png_error, if it fails to allocate the requested * memory. */ png_voidp PNGAPI -png_malloc_warn(png_structp png_ptr, png_uint_32 size) +png_malloc_warn(png_structp png_ptr, png_alloc_size_t size) { png_voidp ptr; png_uint_32 save_flags; @@ -560,34 +578,7 @@ png_malloc_warn(png_structp png_ptr, png_uint_32 size) png_ptr->flags=save_flags; return(ptr); } -#endif - -png_voidp PNGAPI -png_memcpy_check (png_structp png_ptr, png_voidp s1, png_voidp s2, - png_uint_32 length) -{ - png_size_t size; - - size = (png_size_t)length; - if ((png_uint_32)size != length) - png_error(png_ptr, "Overflow in png_memcpy_check."); - - return(png_memcpy (s1, s2, size)); -} -png_voidp PNGAPI -png_memset_check (png_structp png_ptr, png_voidp s1, int value, - png_uint_32 length) -{ - png_size_t size; - - size = (png_size_t)length; - if ((png_uint_32)size != length) - png_error(png_ptr, "Overflow in png_memset_check."); - - return (png_memset (s1, value, size)); - -} #ifdef PNG_USER_MEM_SUPPORTED /* This function is called when the application wants to use another method |