[libpng16] Removed the png_sizeof(), png_strlen(), png_memset(), png_memcpy(),

and png_memcmp() macros.
This commit is contained in:
Glenn Randers-Pehrson 2012-08-10 18:08:02 -05:00
parent dbb7e19fda
commit ece07cfe9c
9 changed files with 81 additions and 574 deletions

View File

@ -435,8 +435,10 @@ Version 1.6.0beta27 [August 10, 2012]
Now "make check" will succeed even if libpng is compiled with -DPNG_NO_READ Now "make check" will succeed even if libpng is compiled with -DPNG_NO_READ
or -DPNG_NO_WRITE. The tests performed are reduced, but the basic reading or -DPNG_NO_WRITE. The tests performed are reduced, but the basic reading
and writing of a PNG file is always tested by one or more of the tests. and writing of a PNG file is always tested by one or more of the tests.
Consistently use memset(), memcpy(), and memcmp() instead of the png_memset(), Consistently use strlen(), memset(), memcpy(), and memcmp() instead of the
png_memcpy(), and png_memcmp() macros. png_strlen(), png_memset(), png_memcpy(), and png_memcmp() macros.
Removed the png_sizeof(), png_strlen(), png_memset(), png_memcpy(), and
png_memcmp() macros.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit (subscription required; visit

View File

@ -4186,8 +4186,10 @@ Version 1.6.0beta27 [August 10, 2012]
Now "make check" will succeed even if libpng is compiled with -DPNG_NO_READ Now "make check" will succeed even if libpng is compiled with -DPNG_NO_READ
or -DPNG_NO_WRITE. The tests performed are reduced, but the basic reading or -DPNG_NO_WRITE. The tests performed are reduced, but the basic reading
and writing of a PNG file is always tested by one or more of the tests. and writing of a PNG file is always tested by one or more of the tests.
Consistently use memset(), memcpy(), and memcmp() instead of the png_memset(), Consistently use strlen(), memset(), memcpy(), and memcmp() instead of the
png_memcpy(), and png_memcmp() macros. png_strlen(), png_memset(), png_memcpy(), and png_memcmp() macros.
Removed the png_sizeof(), png_strlen(), png_memset(), png_memcpy(), and
png_memcmp() macros.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit (subscription required; visit

View File

@ -1,6 +1,6 @@
libpng-manual.txt - A description on how to use and modify libpng libpng-manual.txt - A description on how to use and modify libpng
libpng version 1.6.0beta27 - August 3, 2012 libpng version 1.6.0beta27 - August 10, 2012
Updated and distributed by Glenn Randers-Pehrson Updated and distributed by Glenn Randers-Pehrson
<glennrp at users.sourceforge.net> <glennrp at users.sourceforge.net>
Copyright (c) 1998-2011 Glenn Randers-Pehrson Copyright (c) 1998-2011 Glenn Randers-Pehrson
@ -11,7 +11,7 @@ libpng-manual.txt - A description on how to use and modify libpng
Based on: Based on:
libpng versions 0.97, January 1998, through 1.6.0beta27 - August 3, 2012 libpng versions 0.97, January 1998, through 1.6.0beta27 - August 10, 2012
Updated and distributed by Glenn Randers-Pehrson Updated and distributed by Glenn Randers-Pehrson
Copyright (c) 1998-2011 Glenn Randers-Pehrson Copyright (c) 1998-2011 Glenn Randers-Pehrson
@ -4564,7 +4564,7 @@ directive. It does not matter whether this is placed prior to or after
the '"#include png.h"' directive. the '"#include png.h"' directive.
We moved the png_strcpy(), png_strncpy(), png_strlen(), png_memcpy(), We moved the png_strcpy(), png_strncpy(), png_strlen(), png_memcpy(),
png_memcmp(), png_sprintf, and png_memcpy() macros into a private png_memcmp(), png_sprintf(), and png_memcpy() macros into a private
header file (pngpriv.h) that is not accessible by applications. header file (pngpriv.h) that is not accessible by applications.
In png_get_iCCP, the type of "profile" was changed from png_charpp In png_get_iCCP, the type of "profile" was changed from png_charpp
@ -4874,6 +4874,9 @@ The following has been removed:
with png_get_io_chunk_type(). The new with png_get_io_chunk_type(). The new
function returns a 32-bit integer instead of function returns a 32-bit integer instead of
a string. a string.
The png_sizeof(), png_strlen(), png_strncpy(), png_strcpy(), png_strncpy(),
png_memcpy(), png_memcmp(), png_sprintf(), and png_memset() macros are
no longer used in the libpng sources and have been removed.
XIII. Detecting libpng XIII. Detecting libpng
@ -4993,6 +4996,17 @@ above the comment that says
/* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */ /* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */
We put a space after the "sizeof" operator and we omit the
optional parentheses around its argument when the argument
is an expression, not a type name, and we always enclose the
sizeof operator, with its argument, in parentheses:
(sizeof (png_uint_32))
(sizeof array)
Prior to libpng-1.6.0 we used a "png_sizeof()" macro, formatted as
though it were a function.
To avoid polluting the global namespace, the names of all exported To avoid polluting the global namespace, the names of all exported
functions and variables begin with "png_", and all publicly visible C functions and variables begin with "png_", and all publicly visible C
preprocessor macros begin with "PNG". We request that applications that preprocessor macros begin with "PNG". We request that applications that
@ -5022,7 +5036,7 @@ Other rules can be inferred by inspecting the libpng source.
XVI. Y2K Compliance in libpng XVI. Y2K Compliance in libpng
August 3, 2012 August 10, 2012
Since the PNG Development group is an ad-hoc body, we can't make Since the PNG Development group is an ad-hoc body, we can't make
an official declaration. an official declaration.

561
libpng.3

File diff suppressed because it is too large Load Diff

View File

@ -549,13 +549,6 @@ typedef ptrdiff_t png_ptrdiff_t;
typedef png_size_t png_alloc_size_t; typedef png_size_t png_alloc_size_t;
#endif #endif
/* This macro makes the sizeof operator look and behave like a function, except
* that it can take a type without the enclosing () as an argument so long as
* the type contains no "," characters. As of libpng-1.6.0, this macro is no
* longer used in the libpng source code.
*/
#define png_sizeof(x) (sizeof (x))
/* Prior to 1.6.0 libpng offered limited support for Microsoft C compiler /* Prior to 1.6.0 libpng offered limited support for Microsoft C compiler
* implementations of Intel CPU specific support of user-mode segmented address * implementations of Intel CPU specific support of user-mode segmented address
* spaces, where 16-bit pointers address more than 65536 bytes of memory using * spaces, where 16-bit pointers address more than 65536 bytes of memory using

View File

@ -397,15 +397,6 @@ typedef const png_uint_16p * png_const_uint_16pp;
# endif # endif
#endif #endif
/* Prior to 1.6.0 if _WINDOWS_ was defined 'lstrlenA' and 'CopyMemory' were used
* in place of the ISOC90 functions; this is no longer done in 1.6.0, however
* the use of png_foo as a macro defined to the C function is retained.
*/
#define png_strlen strlen
#define png_memcmp memcmp
#define png_memcpy memcpy
#define png_memset memset
/* These macros may need to be architecture dependent. */ /* These macros may need to be architecture dependent. */
#define PNG_ALIGN_NONE 0 /* do not use data alignment */ #define PNG_ALIGN_NONE 0 /* do not use data alignment */
#define PNG_ALIGN_ALWAYS 1 /* assume unaligned accesses are OK */ #define PNG_ALIGN_ALWAYS 1 /* assume unaligned accesses are OK */

View File

@ -2466,7 +2466,7 @@ png_handle_tEXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
text_info.lang_key = NULL; text_info.lang_key = NULL;
text_info.itxt_length = 0; text_info.itxt_length = 0;
text_info.text = text; text_info.text = text;
text_info.text_length = png_strlen(text); text_info.text_length = strlen(text);
if (png_set_text_2(png_ptr, info_ptr, &text_info, 1)) if (png_set_text_2(png_ptr, info_ptr, &text_info, 1))
png_warning(png_ptr, "Insufficient memory to process text chunk"); png_warning(png_ptr, "Insufficient memory to process text chunk");

View File

@ -299,7 +299,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
|| (nparams > 0 && params == NULL)) || (nparams > 0 && params == NULL))
return; return;
length = png_strlen(purpose) + 1; length = strlen(purpose) + 1;
png_debug1(3, "allocating purpose for info (%lu bytes)", png_debug1(3, "allocating purpose for info (%lu bytes)",
(unsigned long)length); (unsigned long)length);
@ -315,7 +315,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
/* Validate params[nparams] */ /* Validate params[nparams] */
for (i=0; i<nparams; ++i) for (i=0; i<nparams; ++i)
if (params[i] == NULL || if (params[i] == NULL ||
!png_check_fp_string(params[i], png_strlen(params[i]))) !png_check_fp_string(params[i], strlen(params[i])))
png_error(png_ptr, "Invalid format for pCAL parameter"); png_error(png_ptr, "Invalid format for pCAL parameter");
info_ptr->pcal_purpose = png_voidcast(png_charp, info_ptr->pcal_purpose = png_voidcast(png_charp,
@ -335,7 +335,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
info_ptr->pcal_type = (png_byte)type; info_ptr->pcal_type = (png_byte)type;
info_ptr->pcal_nparams = (png_byte)nparams; info_ptr->pcal_nparams = (png_byte)nparams;
length = png_strlen(units) + 1; length = strlen(units) + 1;
png_debug1(3, "allocating units for info (%lu bytes)", png_debug1(3, "allocating units for info (%lu bytes)",
(unsigned long)length); (unsigned long)length);
@ -363,7 +363,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
for (i = 0; i < nparams; i++) for (i = 0; i < nparams; i++)
{ {
length = png_strlen(params[i]) + 1; length = strlen(params[i]) + 1;
png_debug2(3, "allocating parameter %d for info (%lu bytes)", i, png_debug2(3, "allocating parameter %d for info (%lu bytes)", i,
(unsigned long)length); (unsigned long)length);
@ -401,11 +401,11 @@ png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr,
if (unit != 1 && unit != 2) if (unit != 1 && unit != 2)
png_error(png_ptr, "Invalid sCAL unit"); png_error(png_ptr, "Invalid sCAL unit");
if (swidth == NULL || (lengthw = png_strlen(swidth)) == 0 || if (swidth == NULL || (lengthw = strlen(swidth)) == 0 ||
swidth[0] == 45 /* '-' */ || !png_check_fp_string(swidth, lengthw)) swidth[0] == 45 /* '-' */ || !png_check_fp_string(swidth, lengthw))
png_error(png_ptr, "Invalid sCAL width"); png_error(png_ptr, "Invalid sCAL width");
if (sheight == NULL || (lengthh = png_strlen(sheight)) == 0 || if (sheight == NULL || (lengthh = strlen(sheight)) == 0 ||
sheight[0] == 45 /* '-' */ || !png_check_fp_string(sheight, lengthh)) sheight[0] == 45 /* '-' */ || !png_check_fp_string(sheight, lengthh))
png_error(png_ptr, "Invalid sCAL height"); png_error(png_ptr, "Invalid sCAL height");
@ -660,7 +660,7 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
PNG_COLORSPACE_FROM_gAMA|PNG_COLORSPACE_FROM_cHRM; PNG_COLORSPACE_FROM_gAMA|PNG_COLORSPACE_FROM_cHRM;
} }
length = png_strlen(name)+1; length = strlen(name)+1;
new_iccp_name = png_voidcast(png_charp, png_malloc_warn(png_ptr, length)); new_iccp_name = png_voidcast(png_charp, png_malloc_warn(png_ptr, length));
if (new_iccp_name == NULL) if (new_iccp_name == NULL)
@ -783,7 +783,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
continue; continue;
} }
key_len = png_strlen(text_ptr[i].key); key_len = strlen(text_ptr[i].key);
if (text_ptr[i].compression <= 0) if (text_ptr[i].compression <= 0)
{ {
@ -797,13 +797,13 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
/* Set iTXt data */ /* Set iTXt data */
if (text_ptr[i].lang != NULL) if (text_ptr[i].lang != NULL)
lang_len = png_strlen(text_ptr[i].lang); lang_len = strlen(text_ptr[i].lang);
else else
lang_len = 0; lang_len = 0;
if (text_ptr[i].lang_key != NULL) if (text_ptr[i].lang_key != NULL)
lang_key_len = png_strlen(text_ptr[i].lang_key); lang_key_len = strlen(text_ptr[i].lang_key);
else else
lang_key_len = 0; lang_key_len = 0;
@ -829,7 +829,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
else else
{ {
text_length = png_strlen(text_ptr[i].text); text_length = strlen(text_ptr[i].text);
textp->compression = text_ptr[i].compression; textp->compression = text_ptr[i].compression;
} }
@ -1031,7 +1031,7 @@ png_set_sPLT(png_const_structrp png_ptr,
if (from->name == NULL || from->entries == NULL) if (from->name == NULL || from->entries == NULL)
continue; continue;
length = png_strlen(from->name) + 1; length = strlen(from->name) + 1;
to->name = png_voidcast(png_charp, png_malloc_warn(png_ptr, length)); to->name = png_voidcast(png_charp, png_malloc_warn(png_ptr, length));
if (to->name == NULL) if (to->name == NULL)

View File

@ -1607,7 +1607,7 @@ png_write_tEXt(png_structrp png_ptr, png_const_charp key, png_const_charp text,
text_len = 0; text_len = 0;
else else
text_len = png_strlen(text); text_len = strlen(text);
if (text_len > PNG_UINT_31_MAX - (key_len+1)) if (text_len > PNG_UINT_31_MAX - (key_len+1))
png_error(png_ptr, "tEXt: text too long"); png_error(png_ptr, "tEXt: text too long");
@ -1663,7 +1663,7 @@ png_write_zTXt(png_structrp png_ptr, png_const_charp key, png_const_charp text,
/* Compute the compressed data; do it now for the length */ /* Compute the compressed data; do it now for the length */
png_text_compress_init(&comp, (png_const_bytep)text, png_text_compress_init(&comp, (png_const_bytep)text,
text == NULL ? 0 : png_strlen(text)); text == NULL ? 0 : strlen(text));
if (png_text_compress(png_ptr, png_zTXt, &comp, key_len) != Z_OK) if (png_text_compress(png_ptr, png_zTXt, &comp, key_len) != Z_OK)
png_error(png_ptr, png_ptr->zstream.msg); png_error(png_ptr, png_ptr->zstream.msg);
@ -1731,9 +1731,9 @@ png_write_iTXt(png_structrp png_ptr, int compression, png_const_charp key,
* TODO: validate the language tag correctly (see the spec.) * TODO: validate the language tag correctly (see the spec.)
*/ */
if (lang == NULL) lang = ""; /* empty language is valid */ if (lang == NULL) lang = ""; /* empty language is valid */
lang_len = png_strlen(lang)+1; lang_len = strlen(lang)+1;
if (lang_key == NULL) lang_key = ""; /* may be empty */ if (lang_key == NULL) lang_key = ""; /* may be empty */
lang_key_len = png_strlen(lang_key)+1; lang_key_len = strlen(lang_key)+1;
if (text == NULL) text = ""; /* may be empty */ if (text == NULL) text = ""; /* may be empty */
prefix_len = key_len; prefix_len = key_len;
@ -1747,7 +1747,7 @@ png_write_iTXt(png_structrp png_ptr, int compression, png_const_charp key,
else else
prefix_len = (png_uint_32)(prefix_len + lang_key_len); prefix_len = (png_uint_32)(prefix_len + lang_key_len);
png_text_compress_init(&comp, (png_const_bytep)text, png_strlen(text)); png_text_compress_init(&comp, (png_const_bytep)text, strlen(text));
if (compression) if (compression)
{ {
@ -1826,7 +1826,7 @@ png_write_pCAL(png_structrp png_ptr, png_charp purpose, png_int_32 X0,
++purpose_len; /* terminator */ ++purpose_len; /* terminator */
png_debug1(3, "pCAL purpose length = %d", (int)purpose_len); png_debug1(3, "pCAL purpose length = %d", (int)purpose_len);
units_len = png_strlen(units) + (nparams == 0 ? 0 : 1); units_len = strlen(units) + (nparams == 0 ? 0 : 1);
png_debug1(3, "pCAL units length = %d", (int)units_len); png_debug1(3, "pCAL units length = %d", (int)units_len);
total_len = purpose_len + units_len + 10; total_len = purpose_len + units_len + 10;
@ -1838,7 +1838,7 @@ png_write_pCAL(png_structrp png_ptr, png_charp purpose, png_int_32 X0,
*/ */
for (i = 0; i < nparams; i++) for (i = 0; i < nparams; i++)
{ {
params_len[i] = png_strlen(params[i]) + (i == nparams - 1 ? 0 : 1); params_len[i] = strlen(params[i]) + (i == nparams - 1 ? 0 : 1);
png_debug2(3, "pCAL parameter %d length = %lu", i, png_debug2(3, "pCAL parameter %d length = %lu", i,
(unsigned long)params_len[i]); (unsigned long)params_len[i]);
total_len += params_len[i]; total_len += params_len[i];
@ -1875,8 +1875,8 @@ png_write_sCAL_s(png_structrp png_ptr, int unit, png_const_charp width,
png_debug(1, "in png_write_sCAL_s"); png_debug(1, "in png_write_sCAL_s");
wlen = png_strlen(width); wlen = strlen(width);
hlen = png_strlen(height); hlen = strlen(height);
total_len = wlen + hlen + 2; total_len = wlen + hlen + 2;
if (total_len > 64) if (total_len > 64)