/* pngmem.c - stub functions for memory allocation
*
- * libpng version 1.2.6 - August 15, 2004
+ * Last changed in libpng 1.2.13 November 13, 2006
* For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1998-2004 Glenn Randers-Pehrson
+ * Copyright (c) 1998-2006 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.)
*
#define PNG_INTERNAL
#include "png.h"
+#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
+
/* Borland DOS special memory handler */
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
/* if you change this, be sure to change the one in png.h also */
png_voidp ret;
#endif /* PNG_USER_MEM_SUPPORTED */
+ if (png_ptr == NULL || size == 0)
+ return (NULL);
+
#ifdef PNG_MAX_MALLOC_64K
if (size > (png_uint_32)65536L)
{
{
#endif /* PNG_USER_MEM_SUPPORTED */
+ if(png_ptr == NULL) return;
+
if (png_ptr->offset_table != NULL)
{
int i;
png_malloc_warn(png_structp png_ptr, png_uint_32 size)
{
png_voidp ptr;
- png_uint_32 save_flags=png_ptr->flags;
+ png_uint_32 save_flags;
+ if(png_ptr == NULL) return (NULL);
+ save_flags=png_ptr->flags;
png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK;
ptr = (png_voidp)png_malloc((png_structp)png_ptr, size);
png_ptr->flags=save_flags;
png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr
malloc_fn, png_free_ptr free_fn)
{
+ if(png_ptr != NULL) {
png_ptr->mem_ptr = mem_ptr;
png_ptr->malloc_fn = malloc_fn;
png_ptr->free_fn = free_fn;
+ }
}
/* This function returns a pointer to the mem_ptr associated with the user
png_voidp PNGAPI
png_get_mem_ptr(png_structp png_ptr)
{
+ if(png_ptr == NULL) return (NULL);
return ((png_voidp)png_ptr->mem_ptr);
}
#endif /* PNG_USER_MEM_SUPPORTED */
+#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */