mirror of
				https://git.code.sf.net/p/libpng/code.git
				synced 2025-07-10 18:04:09 +02:00 
			
		
		
		
	[libpng16] Simplified png_free_data() in png.c
This commit is contained in:
		
							parent
							
								
									ebba0746bc
								
							
						
					
					
						commit
						bf95fad5f5
					
				
							
								
								
									
										5
									
								
								ANNOUNCE
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								ANNOUNCE
									
									
									
									
									
								
							@ -1,4 +1,4 @@
 | 
				
			|||||||
Libpng 1.6.15beta01 - October 25, 2014
 | 
					Libpng 1.6.15beta01 - October 27, 2014
 | 
				
			||||||
 | 
					
 | 
				
			||||||
This is not intended to be a public release.  It will be replaced
 | 
					This is not intended to be a public release.  It will be replaced
 | 
				
			||||||
within a few weeks by a public version or by another test version.
 | 
					within a few weeks by a public version or by another test version.
 | 
				
			||||||
@ -25,8 +25,9 @@ Other information:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
Changes since the last public release (1.6.14):
 | 
					Changes since the last public release (1.6.14):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Version 1.6.15beta01 [October 25, 2014]
 | 
					Version 1.6.15beta01 [October 27, 2014]
 | 
				
			||||||
  Changed "if (!x)" to "if (x == 0)" and "if (x)" to "if (x !== 0)"
 | 
					  Changed "if (!x)" to "if (x == 0)" and "if (x)" to "if (x !== 0)"
 | 
				
			||||||
 | 
					  Simplified png_free_data().
 | 
				
			||||||
 | 
					
 | 
				
			||||||
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
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										3
									
								
								CHANGES
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								CHANGES
									
									
									
									
									
								
							@ -5033,8 +5033,9 @@ Version 1.6.14rc02 [October 17, 2014]
 | 
				
			|||||||
Version 1.6.14 [October 23, 2014]
 | 
					Version 1.6.14 [October 23, 2014]
 | 
				
			||||||
  No changes.
 | 
					  No changes.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Version 1.6.15beta01 [October 25, 2014]
 | 
					Version 1.6.15beta01 [October 27, 2014]
 | 
				
			||||||
  Changed "if (!x)" to "if (x == 0)" and "if (x)" to "if (x !== 0)"
 | 
					  Changed "if (!x)" to "if (x == 0)" and "if (x)" to "if (x !== 0)"
 | 
				
			||||||
 | 
					  Simplified png_free_data().
 | 
				
			||||||
 | 
					
 | 
				
			||||||
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
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										45
									
								
								png.c
									
									
									
									
									
								
							
							
						
						
									
										45
									
								
								png.c
									
									
									
									
									
								
							@ -451,25 +451,24 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#ifdef PNG_TEXT_SUPPORTED
 | 
					#ifdef PNG_TEXT_SUPPORTED
 | 
				
			||||||
   /* Free text item num or (if num == -1) all text items */
 | 
					   /* Free text item num or (if num == -1) all text items */
 | 
				
			||||||
   if ((mask & PNG_FREE_TEXT) & info_ptr->free_me)
 | 
					   if (info_ptr->text && ((mask & PNG_FREE_TEXT) & info_ptr->free_me))
 | 
				
			||||||
   {
 | 
					   {
 | 
				
			||||||
      if (num != -1)
 | 
					      if (num != -1)
 | 
				
			||||||
      {
 | 
					 | 
				
			||||||
         if (info_ptr->text && info_ptr->text[num].key)
 | 
					 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
         png_free(png_ptr, info_ptr->text[num].key);
 | 
					         png_free(png_ptr, info_ptr->text[num].key);
 | 
				
			||||||
         info_ptr->text[num].key = NULL;
 | 
					         info_ptr->text[num].key = NULL;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
      else
 | 
					      else
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
         int i;
 | 
					         int i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
         for (i = 0; i < info_ptr->num_text; i++)
 | 
					         for (i = 0; i < info_ptr->num_text; i++)
 | 
				
			||||||
             png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, i);
 | 
					            png_free(png_ptr, info_ptr->text[i].key);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
         png_free(png_ptr, info_ptr->text);
 | 
					         png_free(png_ptr, info_ptr->text);
 | 
				
			||||||
         info_ptr->text = NULL;
 | 
					         info_ptr->text = NULL;
 | 
				
			||||||
         info_ptr->num_text=0;
 | 
					         info_ptr->num_text = 0;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
   }
 | 
					   }
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
@ -504,14 +503,14 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
 | 
				
			|||||||
      png_free(png_ptr, info_ptr->pcal_units);
 | 
					      png_free(png_ptr, info_ptr->pcal_units);
 | 
				
			||||||
      info_ptr->pcal_purpose = NULL;
 | 
					      info_ptr->pcal_purpose = NULL;
 | 
				
			||||||
      info_ptr->pcal_units = NULL;
 | 
					      info_ptr->pcal_units = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (info_ptr->pcal_params != NULL)
 | 
					      if (info_ptr->pcal_params != NULL)
 | 
				
			||||||
         {
 | 
					         {
 | 
				
			||||||
            unsigned int i;
 | 
					            int i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            for (i = 0; i < info_ptr->pcal_nparams; i++)
 | 
					            for (i = 0; i < info_ptr->pcal_nparams; i++)
 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
               png_free(png_ptr, info_ptr->pcal_params[i]);
 | 
					               png_free(png_ptr, info_ptr->pcal_params[i]);
 | 
				
			||||||
               info_ptr->pcal_params[i] = NULL;
 | 
					
 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            png_free(png_ptr, info_ptr->pcal_params);
 | 
					            png_free(png_ptr, info_ptr->pcal_params);
 | 
				
			||||||
            info_ptr->pcal_params = NULL;
 | 
					            info_ptr->pcal_params = NULL;
 | 
				
			||||||
         }
 | 
					         }
 | 
				
			||||||
@ -533,26 +532,27 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#ifdef PNG_sPLT_SUPPORTED
 | 
					#ifdef PNG_sPLT_SUPPORTED
 | 
				
			||||||
   /* Free a given sPLT entry, or (if num == -1) all sPLT entries */
 | 
					   /* Free a given sPLT entry, or (if num == -1) all sPLT entries */
 | 
				
			||||||
   if ((mask & PNG_FREE_SPLT) & info_ptr->free_me)
 | 
					   if (info_ptr->splt_palettes && ((mask & PNG_FREE_SPLT) & info_ptr->free_me))
 | 
				
			||||||
   {
 | 
					   {
 | 
				
			||||||
      if (num != -1)
 | 
					      if (num != -1)
 | 
				
			||||||
      {
 | 
					 | 
				
			||||||
         if (info_ptr->splt_palettes)
 | 
					 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
         png_free(png_ptr, info_ptr->splt_palettes[num].name);
 | 
					         png_free(png_ptr, info_ptr->splt_palettes[num].name);
 | 
				
			||||||
         png_free(png_ptr, info_ptr->splt_palettes[num].entries);
 | 
					         png_free(png_ptr, info_ptr->splt_palettes[num].entries);
 | 
				
			||||||
         info_ptr->splt_palettes[num].name = NULL;
 | 
					         info_ptr->splt_palettes[num].name = NULL;
 | 
				
			||||||
         info_ptr->splt_palettes[num].entries = NULL;
 | 
					         info_ptr->splt_palettes[num].entries = NULL;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
      else
 | 
					      else
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
         if (info_ptr->splt_palettes_num)
 | 
					         if (info_ptr->splt_palettes_num)
 | 
				
			||||||
         {
 | 
					         {
 | 
				
			||||||
            int i;
 | 
					            int i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            for (i = 0; i < info_ptr->splt_palettes_num; i++)
 | 
					            for (i = 0; i < info_ptr->splt_palettes_num; i++)
 | 
				
			||||||
               png_free_data(png_ptr, info_ptr, PNG_FREE_SPLT, (int)i);
 | 
					            {
 | 
				
			||||||
 | 
					               png_free(png_ptr, info_ptr->splt_palettes[i].name);
 | 
				
			||||||
 | 
					               png_free(png_ptr, info_ptr->splt_palettes[i].entries);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            png_free(png_ptr, info_ptr->splt_palettes);
 | 
					            png_free(png_ptr, info_ptr->splt_palettes);
 | 
				
			||||||
            info_ptr->splt_palettes = NULL;
 | 
					            info_ptr->splt_palettes = NULL;
 | 
				
			||||||
@ -564,16 +564,13 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
 | 
					#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
 | 
				
			||||||
   if ((mask & PNG_FREE_UNKN) & info_ptr->free_me)
 | 
					   if (info_ptr->unknown_chunks && ((mask & PNG_FREE_UNKN) & info_ptr->free_me))
 | 
				
			||||||
   {
 | 
					   {
 | 
				
			||||||
      if (num != -1)
 | 
					      if (num != -1)
 | 
				
			||||||
      {
 | 
					 | 
				
			||||||
          if (info_ptr->unknown_chunks)
 | 
					 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
          png_free(png_ptr, info_ptr->unknown_chunks[num].data);
 | 
					          png_free(png_ptr, info_ptr->unknown_chunks[num].data);
 | 
				
			||||||
          info_ptr->unknown_chunks[num].data = NULL;
 | 
					          info_ptr->unknown_chunks[num].data = NULL;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
      else
 | 
					      else
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
@ -582,7 +579,7 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
 | 
				
			|||||||
         if (info_ptr->unknown_chunks_num)
 | 
					         if (info_ptr->unknown_chunks_num)
 | 
				
			||||||
         {
 | 
					         {
 | 
				
			||||||
            for (i = 0; i < info_ptr->unknown_chunks_num; i++)
 | 
					            for (i = 0; i < info_ptr->unknown_chunks_num; i++)
 | 
				
			||||||
               png_free_data(png_ptr, info_ptr, PNG_FREE_UNKN, (int)i);
 | 
					               png_free(png_ptr, info_ptr->unknown_chunks[i].data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            png_free(png_ptr, info_ptr->unknown_chunks);
 | 
					            png_free(png_ptr, info_ptr->unknown_chunks);
 | 
				
			||||||
            info_ptr->unknown_chunks = NULL;
 | 
					            info_ptr->unknown_chunks = NULL;
 | 
				
			||||||
@ -619,10 +616,8 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
 | 
				
			|||||||
      {
 | 
					      {
 | 
				
			||||||
         png_uint_32 row;
 | 
					         png_uint_32 row;
 | 
				
			||||||
         for (row = 0; row < info_ptr->height; row++)
 | 
					         for (row = 0; row < info_ptr->height; row++)
 | 
				
			||||||
         {
 | 
					 | 
				
			||||||
            png_free(png_ptr, info_ptr->row_pointers[row]);
 | 
					            png_free(png_ptr, info_ptr->row_pointers[row]);
 | 
				
			||||||
            info_ptr->row_pointers[row] = NULL;
 | 
					
 | 
				
			||||||
         }
 | 
					 | 
				
			||||||
         png_free(png_ptr, info_ptr->row_pointers);
 | 
					         png_free(png_ptr, info_ptr->row_pointers);
 | 
				
			||||||
         info_ptr->row_pointers = NULL;
 | 
					         info_ptr->row_pointers = NULL;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
@ -773,13 +768,13 @@ png_get_copyright(png_const_structrp png_ptr)
 | 
				
			|||||||
#else
 | 
					#else
 | 
				
			||||||
#  ifdef __STDC__
 | 
					#  ifdef __STDC__
 | 
				
			||||||
   return PNG_STRING_NEWLINE \
 | 
					   return PNG_STRING_NEWLINE \
 | 
				
			||||||
     "libpng version 1.6.15beta01 - October 25, 2014" PNG_STRING_NEWLINE \
 | 
					     "libpng version 1.6.15beta01 - October 27, 2014" PNG_STRING_NEWLINE \
 | 
				
			||||||
     "Copyright (c) 1998-2014 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
 | 
					     "Copyright (c) 1998-2014 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 "libpng version 1.6.15beta01 - October 25, 2014\
 | 
					      return "libpng version 1.6.15beta01 - October 27, 2014\
 | 
				
			||||||
      Copyright (c) 1998-2014 Glenn Randers-Pehrson\
 | 
					      Copyright (c) 1998-2014 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.";
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user