[devel] Fix indentation in png.c, pngmem,c, pngrio.c, and pngwio.c

This commit is contained in:
Glenn Randers-Pehrson
2010-03-06 13:54:59 -06:00
parent e8b1aa0c5a
commit 6f6a91a131
4 changed files with 107 additions and 107 deletions

58
png.c
View File

@@ -483,7 +483,7 @@ png_get_io_ptr(png_structp png_ptr)
} }
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
#ifdef PNG_STDIO_SUPPORTED # ifdef PNG_STDIO_SUPPORTED
/* Initialize the default input/output functions for the PNG file. If you /* Initialize the default input/output functions for the PNG file. If you
* use your own read or write routines, you can call either png_set_read_fn() * use your own read or write routines, you can call either png_set_read_fn()
* or png_set_write_fn() instead of png_init_io(). If you have defined * or png_set_write_fn() instead of png_init_io(). If you have defined
@@ -500,9 +500,9 @@ png_init_io(png_structp png_ptr, png_FILE_p fp)
png_ptr->io_ptr = (png_voidp)fp; png_ptr->io_ptr = (png_voidp)fp;
} }
#endif # endif
#ifdef PNG_TIME_RFC1123_SUPPORTED # ifdef PNG_TIME_RFC1123_SUPPORTED
/* Convert the supplied time into an RFC 1123 string suitable for use in /* Convert the supplied time into an RFC 1123 string suitable for use in
* a "Creation Time" or other text-based time string. * a "Creation Time" or other text-based time string.
*/ */
@@ -521,7 +521,7 @@ png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
png_sizeof(char))); png_sizeof(char)));
} }
#ifdef USE_FAR_KEYWORD # ifdef USE_FAR_KEYWORD
{ {
char near_time_buf[29]; char near_time_buf[29];
png_snprintf6(near_time_buf, 29, "%d %s %d %02d:%02d:%02d +0000", png_snprintf6(near_time_buf, 29, "%d %s %d %02d:%02d:%02d +0000",
@@ -531,15 +531,15 @@ png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
png_memcpy(png_ptr->time_buffer, near_time_buf, png_memcpy(png_ptr->time_buffer, near_time_buf,
29*png_sizeof(char)); 29*png_sizeof(char));
} }
#else # else
png_snprintf6(png_ptr->time_buffer, 29, "%d %s %d %02d:%02d:%02d +0000", png_snprintf6(png_ptr->time_buffer, 29, "%d %s %d %02d:%02d:%02d +0000",
ptime->day % 32, short_months[(ptime->month - 1) % 12], ptime->day % 32, short_months[(ptime->month - 1) % 12],
ptime->year, ptime->hour % 24, ptime->minute % 60, ptime->year, ptime->hour % 24, ptime->minute % 60,
ptime->second % 61); ptime->second % 61);
#endif # endif
return ((png_charp)png_ptr->time_buffer); return ((png_charp)png_ptr->time_buffer);
} }
#endif /* PNG_TIME_RFC1123_SUPPORTED */ # endif /* PNG_TIME_RFC1123_SUPPORTED */
#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ #endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
@@ -550,19 +550,19 @@ png_get_copyright(png_structp png_ptr)
#ifdef PNG_STRING_COPYRIGHT #ifdef PNG_STRING_COPYRIGHT
return PNG_STRING_COPYRIGHT return PNG_STRING_COPYRIGHT
#else #else
#ifdef __STDC__ # ifdef __STDC__
return ((png_charp) PNG_STRING_NEWLINE \ return ((png_charp) PNG_STRING_NEWLINE \
"libpng version 1.5.0beta11 - March 3, 2010" PNG_STRING_NEWLINE \ "libpng version 1.5.0beta11 - March 3, 2010" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2010 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \ "Copyright (c) 1998-2010 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \ "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \ "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
PNG_STRING_NEWLINE); PNG_STRING_NEWLINE);
#else # else
return ((png_charp) "libpng version 1.5.0beta11 - March 3, 2010\ return ((png_charp) "libpng version 1.5.0beta11 - March 3, 2010\
Copyright (c) 1998-2010 Glenn Randers-Pehrson\ Copyright (c) 1998-2010 Glenn Randers-Pehrson\
Copyright (c) 1996-1997 Andreas Dilger\ Copyright (c) 1996-1997 Andreas Dilger\
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc."); Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.");
#endif # endif
#endif #endif
} }
@@ -597,9 +597,9 @@ png_get_header_version(png_structp png_ptr)
png_ptr = png_ptr; /* Silence compiler warning about unused png_ptr */ png_ptr = png_ptr; /* Silence compiler warning about unused png_ptr */
#ifdef __STDC__ #ifdef __STDC__
return ((png_charp) PNG_HEADER_VERSION_STRING return ((png_charp) PNG_HEADER_VERSION_STRING
#ifndef PNG_READ_SUPPORTED # ifndef PNG_READ_SUPPORTED
" (NO READ SUPPORT)" " (NO READ SUPPORT)"
#endif # endif
PNG_STRING_NEWLINE); PNG_STRING_NEWLINE);
#else #else
return ((png_charp) PNG_HEADER_VERSION_STRING); return ((png_charp) PNG_HEADER_VERSION_STRING);
@@ -607,7 +607,7 @@ png_get_header_version(png_structp png_ptr)
} }
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED # ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
int PNGAPI int PNGAPI
png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name) png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name)
{ {
@@ -622,7 +622,7 @@ png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name)
return ((int)*(p + 4)); return ((int)*(p + 4));
return 0; return 0;
} }
#endif # endif
/* This function, added to libpng-1.0.6g, is untested. */ /* This function, added to libpng-1.0.6g, is untested. */
int PNGAPI int PNGAPI
@@ -645,7 +645,7 @@ png_access_version_number(void)
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
#ifdef PNG_SIZE_T # ifdef PNG_SIZE_T
/* Added at libpng version 1.2.6 */ /* Added at libpng version 1.2.6 */
PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size)); PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size));
png_size_t PNGAPI png_size_t PNGAPI
@@ -655,11 +655,11 @@ png_convert_size(size_t size)
PNG_ABORT(); /* We haven't got access to png_ptr, so no png_error() */ PNG_ABORT(); /* We haven't got access to png_ptr, so no png_error() */
return ((png_size_t)size); return ((png_size_t)size);
} }
#endif /* PNG_SIZE_T */ # endif /* PNG_SIZE_T */
/* Added at libpng version 1.2.34 and 1.4.0 (moved from pngset.c) */ /* Added at libpng version 1.2.34 and 1.4.0 (moved from pngset.c) */
#ifdef PNG_cHRM_SUPPORTED # ifdef PNG_cHRM_SUPPORTED
#ifdef PNG_CHECK_cHRM_SUPPORTED # ifdef PNG_CHECK_cHRM_SUPPORTED
/* /*
* Multiply two 32-bit numbers, V1 and V2, using 32-bit * Multiply two 32-bit numbers, V1 and V2, using 32-bit
@@ -770,8 +770,8 @@ png_check_cHRM_fixed(png_structp png_ptr,
return ret; return ret;
} }
#endif /* PNG_CHECK_cHRM_SUPPORTED */ # endif /* PNG_CHECK_cHRM_SUPPORTED */
#endif /* PNG_cHRM_SUPPORTED */ # endif /* PNG_cHRM_SUPPORTED */
void /* PRIVATE */ void /* PRIVATE */
png_check_IHDR(png_structp png_ptr, png_check_IHDR(png_structp png_ptr,
@@ -794,21 +794,21 @@ png_check_IHDR(png_structp png_ptr,
error = 1; error = 1;
} }
#ifdef PNG_SET_USER_LIMITS_SUPPORTED # ifdef PNG_SET_USER_LIMITS_SUPPORTED
if (width > png_ptr->user_width_max || width > PNG_USER_WIDTH_MAX) if (width > png_ptr->user_width_max || width > PNG_USER_WIDTH_MAX)
#else # else
if (width > PNG_USER_WIDTH_MAX) if (width > PNG_USER_WIDTH_MAX)
#endif # endif
{ {
png_warning(png_ptr, "Image width exceeds user limit in IHDR"); png_warning(png_ptr, "Image width exceeds user limit in IHDR");
error = 1; error = 1;
} }
#ifdef PNG_SET_USER_LIMITS_SUPPORTED # ifdef PNG_SET_USER_LIMITS_SUPPORTED
if (height > png_ptr->user_height_max || height > PNG_USER_HEIGHT_MAX) if (height > png_ptr->user_height_max || height > PNG_USER_HEIGHT_MAX)
#else # else
if (height > PNG_USER_HEIGHT_MAX) if (height > PNG_USER_HEIGHT_MAX)
#endif # endif
{ {
png_warning(png_ptr, "Image height exceeds user limit in IHDR"); png_warning(png_ptr, "Image height exceeds user limit in IHDR");
error = 1; error = 1;
@@ -870,7 +870,7 @@ png_check_IHDR(png_structp png_ptr,
error = 1; error = 1;
} }
#ifdef PNG_MNG_FEATURES_SUPPORTED # ifdef PNG_MNG_FEATURES_SUPPORTED
/* Accept filter_method 64 (intrapixel differencing) only if /* Accept filter_method 64 (intrapixel differencing) only if
* 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and
* 2. Libpng did not read a PNG signature (this filter_method is only * 2. Libpng did not read a PNG signature (this filter_method is only
@@ -903,13 +903,13 @@ png_check_IHDR(png_structp png_ptr,
} }
} }
#else # else
if (filter_type != PNG_FILTER_TYPE_BASE) if (filter_type != PNG_FILTER_TYPE_BASE)
{ {
png_warning(png_ptr, "Unknown filter method in IHDR"); png_warning(png_ptr, "Unknown filter method in IHDR");
error = 1; error = 1;
} }
#endif # endif
if (error == 1) if (error == 1)
png_error(png_ptr, "Invalid IHDR data"); png_error(png_ptr, "Invalid IHDR data");

132
pngmem.c
View File

@@ -32,7 +32,7 @@
png_voidp /* PRIVATE */ png_voidp /* PRIVATE */
png_create_struct(int type) png_create_struct(int type)
{ {
#ifdef PNG_USER_MEM_SUPPORTED # ifdef PNG_USER_MEM_SUPPORTED
return (png_create_struct_2(type, NULL, NULL)); return (png_create_struct_2(type, NULL, NULL));
} }
@@ -40,7 +40,7 @@ png_create_struct(int type)
png_voidp /* PRIVATE */ png_voidp /* PRIVATE */
png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr) png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr)
{ {
#endif /* PNG_USER_MEM_SUPPORTED */ # endif /* PNG_USER_MEM_SUPPORTED */
png_size_t size; png_size_t size;
png_voidp struct_ptr; png_voidp struct_ptr;
@@ -51,7 +51,7 @@ png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr)
else else
return (png_get_copyright(NULL)); return (png_get_copyright(NULL));
#ifdef PNG_USER_MEM_SUPPORTED # ifdef PNG_USER_MEM_SUPPORTED
if (malloc_fn != NULL) if (malloc_fn != NULL)
{ {
png_struct dummy_struct; png_struct dummy_struct;
@@ -60,7 +60,7 @@ png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr)
struct_ptr = (*(malloc_fn))(png_ptr, (png_uint_32)size); struct_ptr = (*(malloc_fn))(png_ptr, (png_uint_32)size);
} }
else else
#endif /* PNG_USER_MEM_SUPPORTED */ # endif /* PNG_USER_MEM_SUPPORTED */
struct_ptr = (png_voidp)farmalloc(size); struct_ptr = (png_voidp)farmalloc(size);
if (struct_ptr != NULL) if (struct_ptr != NULL)
png_memset(struct_ptr, 0, size); png_memset(struct_ptr, 0, size);
@@ -71,7 +71,7 @@ png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr)
void /* PRIVATE */ void /* PRIVATE */
png_destroy_struct(png_voidp struct_ptr) png_destroy_struct(png_voidp struct_ptr)
{ {
#ifdef PNG_USER_MEM_SUPPORTED # ifdef PNG_USER_MEM_SUPPORTED
png_destroy_struct_2(struct_ptr, NULL, NULL); png_destroy_struct_2(struct_ptr, NULL, NULL);
} }
@@ -80,10 +80,10 @@ void /* PRIVATE */
png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
png_voidp mem_ptr) png_voidp mem_ptr)
{ {
#endif # endif
if (struct_ptr != NULL) if (struct_ptr != NULL)
{ {
#ifdef PNG_USER_MEM_SUPPORTED # ifdef PNG_USER_MEM_SUPPORTED
if (free_fn != NULL) if (free_fn != NULL)
{ {
png_struct dummy_struct; png_struct dummy_struct;
@@ -92,7 +92,7 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
(*(free_fn))(png_ptr, struct_ptr); (*(free_fn))(png_ptr, struct_ptr);
return; return;
} }
#endif /* PNG_USER_MEM_SUPPORTED */ # endif /* PNG_USER_MEM_SUPPORTED */
farfree (struct_ptr); farfree (struct_ptr);
} }
} }
@@ -135,7 +135,7 @@ png_malloc(png_structp png_ptr, png_alloc_size_t size)
if (png_ptr == NULL || size == 0) if (png_ptr == NULL || size == 0)
return (NULL); return (NULL);
#ifdef PNG_USER_MEM_SUPPORTED # ifdef PNG_USER_MEM_SUPPORTED
if (png_ptr->malloc_fn != NULL) if (png_ptr->malloc_fn != NULL)
ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size)); ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size));
else else
@@ -149,19 +149,19 @@ png_voidp PNGAPI
png_malloc_default(png_structp png_ptr, png_alloc_size_t size) png_malloc_default(png_structp png_ptr, png_alloc_size_t size)
{ {
png_voidp ret; png_voidp ret;
#endif /* PNG_USER_MEM_SUPPORTED */ # endif /* PNG_USER_MEM_SUPPORTED */
if (png_ptr == NULL || size == 0) if (png_ptr == NULL || size == 0)
return (NULL); return (NULL);
#ifdef PNG_MAX_MALLOC_64K # ifdef PNG_MAX_MALLOC_64K
if (size > (png_uint_32)65536L) if (size > (png_uint_32)65536L)
{ {
png_warning(png_ptr, "Cannot Allocate > 64K"); png_warning(png_ptr, "Cannot Allocate > 64K");
ret = NULL; ret = NULL;
} }
else else
#endif # endif
if (size != (size_t)size) if (size != (size_t)size)
ret = NULL; ret = NULL;
@@ -200,25 +200,25 @@ png_malloc_default(png_structp png_ptr, png_alloc_size_t size)
if (table == NULL) if (table == NULL)
{ {
#ifndef PNG_USER_MEM_SUPPORTED # ifndef PNG_USER_MEM_SUPPORTED
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
png_error(png_ptr, "Out Of Memory"); /* Note "O", "M" */ png_error(png_ptr, "Out Of Memory"); /* Note "O", "M" */
else else
png_warning(png_ptr, "Out Of Memory"); png_warning(png_ptr, "Out Of Memory");
#endif # endif
return (NULL); return (NULL);
} }
if ((png_size_t)table & 0xfff0) if ((png_size_t)table & 0xfff0)
{ {
#ifndef PNG_USER_MEM_SUPPORTED # ifndef PNG_USER_MEM_SUPPORTED
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
png_error(png_ptr, png_error(png_ptr,
"Farmalloc didn't return normalized pointer"); "Farmalloc didn't return normalized pointer");
else else
png_warning(png_ptr, png_warning(png_ptr,
"Farmalloc didn't return normalized pointer"); "Farmalloc didn't return normalized pointer");
#endif # endif
return (NULL); return (NULL);
} }
@@ -228,12 +228,12 @@ png_malloc_default(png_structp png_ptr, png_alloc_size_t size)
if (png_ptr->offset_table_ptr == NULL) if (png_ptr->offset_table_ptr == NULL)
{ {
#ifndef PNG_USER_MEM_SUPPORTED # ifndef PNG_USER_MEM_SUPPORTED
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
png_error(png_ptr, "Out Of memory"); /* Note "O", "m" */ png_error(png_ptr, "Out Of memory"); /* Note "O", "m" */
else else
png_warning(png_ptr, "Out Of memory"); png_warning(png_ptr, "Out Of memory");
#endif # endif
return (NULL); return (NULL);
} }
@@ -257,12 +257,12 @@ png_malloc_default(png_structp png_ptr, png_alloc_size_t size)
if (png_ptr->offset_table_count >= png_ptr->offset_table_number) if (png_ptr->offset_table_count >= png_ptr->offset_table_number)
{ {
#ifndef PNG_USER_MEM_SUPPORTED # ifndef PNG_USER_MEM_SUPPORTED
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) 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 else
png_warning(png_ptr, "Out of Memory"); png_warning(png_ptr, "Out of Memory");
#endif # endif
return (NULL); return (NULL);
} }
@@ -271,7 +271,7 @@ png_malloc_default(png_structp png_ptr, png_alloc_size_t size)
else else
ret = farmalloc(size); ret = farmalloc(size);
#ifndef PNG_USER_MEM_SUPPORTED # ifndef PNG_USER_MEM_SUPPORTED
if (ret == NULL) if (ret == NULL)
{ {
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
@@ -279,7 +279,7 @@ png_malloc_default(png_structp png_ptr, png_alloc_size_t size)
else else
png_warning(png_ptr, "Out of memory"); /* Note "o" and "m" */ png_warning(png_ptr, "Out of memory"); /* Note "o" and "m" */
} }
#endif # endif
return (ret); return (ret);
} }
@@ -294,7 +294,7 @@ png_free(png_structp png_ptr, png_voidp ptr)
if (png_ptr == NULL || ptr == NULL) if (png_ptr == NULL || ptr == NULL)
return; return;
#ifdef PNG_USER_MEM_SUPPORTED # ifdef PNG_USER_MEM_SUPPORTED
if (png_ptr->free_fn != NULL) if (png_ptr->free_fn != NULL)
{ {
(*(png_ptr->free_fn))(png_ptr, ptr); (*(png_ptr->free_fn))(png_ptr, ptr);
@@ -307,7 +307,7 @@ png_free(png_structp png_ptr, png_voidp ptr)
void PNGAPI void PNGAPI
png_free_default(png_structp png_ptr, png_voidp ptr) png_free_default(png_structp png_ptr, png_voidp ptr)
{ {
#endif /* PNG_USER_MEM_SUPPORTED */ # endif /* PNG_USER_MEM_SUPPORTED */
if (png_ptr == NULL || ptr == NULL) if (png_ptr == NULL || ptr == NULL)
return; return;
@@ -348,7 +348,7 @@ png_free_default(png_structp png_ptr, png_voidp ptr)
png_voidp /* PRIVATE */ png_voidp /* PRIVATE */
png_create_struct(int type) png_create_struct(int type)
{ {
#ifdef PNG_USER_MEM_SUPPORTED # ifdef PNG_USER_MEM_SUPPORTED
return (png_create_struct_2(type, NULL, NULL)); return (png_create_struct_2(type, NULL, NULL));
} }
@@ -358,7 +358,7 @@ png_create_struct(int type)
png_voidp /* PRIVATE */ png_voidp /* PRIVATE */
png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr) png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr)
{ {
#endif /* PNG_USER_MEM_SUPPORTED */ # endif /* PNG_USER_MEM_SUPPORTED */
png_size_t size; png_size_t size;
png_voidp struct_ptr; png_voidp struct_ptr;
@@ -369,7 +369,7 @@ png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr)
else else
return (NULL); return (NULL);
#ifdef PNG_USER_MEM_SUPPORTED # ifdef PNG_USER_MEM_SUPPORTED
if (malloc_fn != NULL) if (malloc_fn != NULL)
{ {
png_struct dummy_struct; png_struct dummy_struct;
@@ -380,17 +380,17 @@ png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr)
png_memset(struct_ptr, 0, size); png_memset(struct_ptr, 0, size);
return (struct_ptr); return (struct_ptr);
} }
#endif /* PNG_USER_MEM_SUPPORTED */ # endif /* PNG_USER_MEM_SUPPORTED */
#if defined(__TURBOC__) && !defined(__FLAT__) # if defined(__TURBOC__) && !defined(__FLAT__)
struct_ptr = (png_voidp)farmalloc(size); struct_ptr = (png_voidp)farmalloc(size);
#else # else
# if defined(_MSC_VER) && defined(MAXSEG_64K) # if defined(_MSC_VER) && defined(MAXSEG_64K)
struct_ptr = (png_voidp)halloc(size, 1); struct_ptr = (png_voidp)halloc(size, 1);
# else # else
struct_ptr = (png_voidp)malloc(size); struct_ptr = (png_voidp)malloc(size);
# endif # endif
#endif # endif
if (struct_ptr != NULL) if (struct_ptr != NULL)
png_memset(struct_ptr, 0, size); png_memset(struct_ptr, 0, size);
@@ -402,7 +402,7 @@ png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr)
void /* PRIVATE */ void /* PRIVATE */
png_destroy_struct(png_voidp struct_ptr) png_destroy_struct(png_voidp struct_ptr)
{ {
#ifdef PNG_USER_MEM_SUPPORTED # ifdef PNG_USER_MEM_SUPPORTED
png_destroy_struct_2(struct_ptr, NULL, NULL); png_destroy_struct_2(struct_ptr, NULL, NULL);
} }
@@ -411,10 +411,10 @@ void /* PRIVATE */
png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
png_voidp mem_ptr) png_voidp mem_ptr)
{ {
#endif /* PNG_USER_MEM_SUPPORTED */ # endif /* PNG_USER_MEM_SUPPORTED */
if (struct_ptr != NULL) if (struct_ptr != NULL)
{ {
#ifdef PNG_USER_MEM_SUPPORTED # ifdef PNG_USER_MEM_SUPPORTED
if (free_fn != NULL) if (free_fn != NULL)
{ {
png_struct dummy_struct; png_struct dummy_struct;
@@ -423,16 +423,16 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
(*(free_fn))(png_ptr, struct_ptr); (*(free_fn))(png_ptr, struct_ptr);
return; return;
} }
#endif /* PNG_USER_MEM_SUPPORTED */ # endif /* PNG_USER_MEM_SUPPORTED */
#if defined(__TURBOC__) && !defined(__FLAT__) # if defined(__TURBOC__) && !defined(__FLAT__)
farfree(struct_ptr); farfree(struct_ptr);
#else # else
# if defined(_MSC_VER) && defined(MAXSEG_64K) # if defined(_MSC_VER) && defined(MAXSEG_64K)
hfree(struct_ptr); hfree(struct_ptr);
# else # else
free(struct_ptr); free(struct_ptr);
# endif # endif
#endif # endif
} }
} }
@@ -459,7 +459,7 @@ png_malloc(png_structp png_ptr, png_alloc_size_t size)
{ {
png_voidp ret; png_voidp ret;
#ifdef PNG_USER_MEM_SUPPORTED # ifdef PNG_USER_MEM_SUPPORTED
if (png_ptr == NULL || size == 0) if (png_ptr == NULL || size == 0)
return (NULL); return (NULL);
@@ -476,47 +476,47 @@ png_voidp PNGAPI
png_malloc_default(png_structp png_ptr, png_alloc_size_t size) png_malloc_default(png_structp png_ptr, png_alloc_size_t size)
{ {
png_voidp ret; png_voidp ret;
#endif /* PNG_USER_MEM_SUPPORTED */ # endif /* PNG_USER_MEM_SUPPORTED */
if (png_ptr == NULL || size == 0) if (png_ptr == NULL || size == 0)
return (NULL); return (NULL);
#ifdef PNG_MAX_MALLOC_64K # ifdef PNG_MAX_MALLOC_64K
if (size > (png_uint_32)65536L) if (size > (png_uint_32)65536L)
{ {
#ifndef PNG_USER_MEM_SUPPORTED # ifndef PNG_USER_MEM_SUPPORTED
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
png_error(png_ptr, "Cannot Allocate > 64K"); png_error(png_ptr, "Cannot Allocate > 64K");
else else
#endif # endif
return NULL; return NULL;
} }
#endif # endif
/* Check for overflow */ /* Check for overflow */
#if defined(__TURBOC__) && !defined(__FLAT__) # if defined(__TURBOC__) && !defined(__FLAT__)
if (size != (unsigned long)size) if (size != (unsigned long)size)
ret = NULL; ret = NULL;
else else
ret = farmalloc(size); ret = farmalloc(size);
#else # else
# if defined(_MSC_VER) && defined(MAXSEG_64K) # if defined(_MSC_VER) && defined(MAXSEG_64K)
if (size != (unsigned long)size) if (size != (unsigned long)size)
ret = NULL; ret = NULL;
else else
ret = halloc(size, 1); ret = halloc(size, 1);
# else # else
if (size != (size_t)size) if (size != (size_t)size)
ret = NULL; ret = NULL;
else else
ret = malloc((size_t)size); ret = malloc((size_t)size);
# endif # endif
#endif # endif
#ifndef PNG_USER_MEM_SUPPORTED # ifndef PNG_USER_MEM_SUPPORTED
if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) 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");
#endif # endif
return (ret); return (ret);
} }
@@ -530,7 +530,7 @@ png_free(png_structp png_ptr, png_voidp ptr)
if (png_ptr == NULL || ptr == NULL) if (png_ptr == NULL || ptr == NULL)
return; return;
#ifdef PNG_USER_MEM_SUPPORTED # ifdef PNG_USER_MEM_SUPPORTED
if (png_ptr->free_fn != NULL) if (png_ptr->free_fn != NULL)
{ {
(*(png_ptr->free_fn))(png_ptr, ptr); (*(png_ptr->free_fn))(png_ptr, ptr);
@@ -545,17 +545,17 @@ png_free_default(png_structp png_ptr, png_voidp ptr)
if (png_ptr == NULL || ptr == NULL) if (png_ptr == NULL || ptr == NULL)
return; return;
#endif /* PNG_USER_MEM_SUPPORTED */ # endif /* PNG_USER_MEM_SUPPORTED */
#if defined(__TURBOC__) && !defined(__FLAT__) # if defined(__TURBOC__) && !defined(__FLAT__)
farfree(ptr); farfree(ptr);
#else # else
# if defined(_MSC_VER) && defined(MAXSEG_64K) # if defined(_MSC_VER) && defined(MAXSEG_64K)
hfree(ptr); hfree(ptr);
# else # else
free(ptr); free(ptr);
# endif # endif
#endif # endif
} }
#endif /* Not Borland DOS special memory handler */ #endif /* Not Borland DOS special memory handler */

View File

@@ -47,7 +47,7 @@ png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
* read_data function and use it at run time with png_set_read_fn(), rather * read_data function and use it at run time with png_set_read_fn(), rather
* than changing the library. * than changing the library.
*/ */
#ifndef USE_FAR_KEYWORD # ifndef USE_FAR_KEYWORD
void PNGAPI void PNGAPI
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
{ {
@@ -63,7 +63,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
if (check != length) if (check != length)
png_error(png_ptr, "Read Error"); png_error(png_ptr, "Read Error");
} }
#else # else
/* This is the model-independent version. Since the standard I/O library /* This is the model-independent version. Since the standard I/O library
can't handle far buffers in the medium and small models, we have to copy can't handle far buffers in the medium and small models, we have to copy
the data. the data.
@@ -111,7 +111,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
if ((png_uint_32)check != (png_uint_32)length) if ((png_uint_32)check != (png_uint_32)length)
png_error(png_ptr, "read Error"); png_error(png_ptr, "read Error");
} }
#endif # endif
#endif #endif
/* This function allows the application to supply a new input function /* This function allows the application to supply a new input function

View File

@@ -124,7 +124,7 @@ png_flush(png_structp png_ptr)
(*(png_ptr->output_flush_fn))(png_ptr); (*(png_ptr->output_flush_fn))(png_ptr);
} }
#ifdef PNG_STDIO_SUPPORTED # ifdef PNG_STDIO_SUPPORTED
void PNGAPI void PNGAPI
png_default_flush(png_structp png_ptr) png_default_flush(png_structp png_ptr)
{ {
@@ -134,7 +134,7 @@ png_default_flush(png_structp png_ptr)
io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr)); io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr));
fflush(io_ptr); fflush(io_ptr);
} }
#endif # endif
#endif #endif
/* This function allows the application to supply new output functions for /* This function allows the application to supply new output functions for
@@ -168,7 +168,7 @@ png_default_flush(png_structp png_ptr)
*/ */
void PNGAPI void PNGAPI
png_set_write_fn(png_structp png_ptr, png_voidp io_ptr, png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn) png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
{ {
if (png_ptr == NULL) if (png_ptr == NULL)
return; return;
@@ -186,15 +186,15 @@ png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
#endif #endif
#ifdef PNG_WRITE_FLUSH_SUPPORTED #ifdef PNG_WRITE_FLUSH_SUPPORTED
#ifdef PNG_STDIO_SUPPORTED # ifdef PNG_STDIO_SUPPORTED
if (output_flush_fn != NULL) if (output_flush_fn != NULL)
png_ptr->output_flush_fn = output_flush_fn; png_ptr->output_flush_fn = output_flush_fn;
else else
png_ptr->output_flush_fn = png_default_flush; png_ptr->output_flush_fn = png_default_flush;
#else # else
png_ptr->output_flush_fn = output_flush_fn; png_ptr->output_flush_fn = output_flush_fn;
#endif # endif
#endif /* PNG_WRITE_FLUSH_SUPPORTED */ #endif /* PNG_WRITE_FLUSH_SUPPORTED */
/* It is an error to read while writing a png file */ /* It is an error to read while writing a png file */
@@ -209,7 +209,7 @@ png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
} }
#ifdef USE_FAR_KEYWORD #ifdef USE_FAR_KEYWORD
#ifdef _MSC_VER # ifdef _MSC_VER
void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check) void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check)
{ {
void *near_ptr; void *near_ptr;
@@ -237,6 +237,6 @@ void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check)
return(near_ptr); return(near_ptr);
} }
# endif # endif
# endif #endif
#endif /* PNG_WRITE_SUPPORTED */ #endif /* PNG_WRITE_SUPPORTED */