void PNGAPI png_set_pCAL ( png_structp png_ptr , png_infop info_ptr , png_charp purpose , png_int_32 X0 , png_int_32 X1 , int type , int nparams , png_charp units , png_charpp params ) {
 png_uint_32 length ;
 int i ;
 png_debug1 ( 1 , "in %s storage function" , "pCAL" ) ;
 if ( png_ptr == NULL || info_ptr == NULL ) return ;
 length = png_strlen ( purpose ) + 1 ;
 png_debug1 ( 3 , "allocating purpose for info (%lu bytes)" , ( unsigned long ) length ) ;
 info_ptr -> pcal_purpose = ( png_charp ) png_malloc_warn ( png_ptr , length ) ;
 if ( info_ptr -> pcal_purpose == NULL ) {
 png_warning ( png_ptr , "Insufficient memory for pCAL purpose." ) ;
 return ;
 }
 png_memcpy ( info_ptr -> pcal_purpose , purpose , ( png_size_t ) length ) ;
 png_debug ( 3 , "storing X0, X1, type, and nparams in info" ) ;
 info_ptr -> pcal_X0 = X0 ;
 info_ptr -> pcal_X1 = X1 ;
 info_ptr -> pcal_type = ( png_byte ) type ;
 info_ptr -> pcal_nparams = ( png_byte ) nparams ;
 length = png_strlen ( units ) + 1 ;
 png_debug1 ( 3 , "allocating units for info (%lu bytes)" , ( unsigned long ) length ) ;
 info_ptr -> pcal_units = ( png_charp ) png_malloc_warn ( png_ptr , length ) ;
 if ( info_ptr -> pcal_units == NULL ) {
 png_warning ( png_ptr , "Insufficient memory for pCAL units." ) ;
 return ;
 }
 png_memcpy ( info_ptr -> pcal_units , units , ( png_size_t ) length ) ;
 info_ptr -> pcal_params = ( png_charpp ) png_malloc_warn ( png_ptr , ( png_uint_32 ) ( ( nparams + 1 ) * png_sizeof ( png_charp ) ) ) ;
 if ( info_ptr -> pcal_params == NULL ) {
 png_warning ( png_ptr , "Insufficient memory for pCAL params." ) ;
 return ;
 }
 png_memset ( info_ptr -> pcal_params , 0 , ( nparams + 1 ) * png_sizeof ( png_charp ) ) ;
 for ( i = 0 ;
 i < nparams ;
 i ++ ) {
 length = png_strlen ( params [ i ] ) + 1 ;
 png_debug2 ( 3 , "allocating parameter %d for info (%lu bytes)" , i , ( unsigned long ) length ) ;
 info_ptr -> pcal_params [ i ] = ( png_charp ) png_malloc_warn ( png_ptr , length ) ;
 if ( info_ptr -> pcal_params [ i ] == NULL ) {
 png_warning ( png_ptr , "Insufficient memory for pCAL parameter." ) ;
 return ;
 }
 png_memcpy ( info_ptr -> pcal_params [ i ] , params [ i ] , ( png_size_t ) length ) ;
 }
 info_ptr -> valid |= PNG_INFO_pCAL ;
 # ifdef PNG_FREE_ME_SUPPORTED info_ptr -> free_me |= PNG_FREE_PCAL ;
 # endif }
void PNGAPI png_set_pCAL ( png_structp png_ptr , png_infop info_ptr , png_charp purpose , png_int_32 X0 , png_int_32 X1 , int type , int nparams , png_charp units , png_charpp params ) {
 png_uint_32 length ;
 int i ;
 png_debug1 ( 1 , "in %s storage function" , "pCAL" ) ;
 if ( png_ptr == NULL || info_ptr == NULL ) return ;
 length = png_strlen ( purpose ) + 1 ;
 png_debug1 ( 3 , "allocating purpose for info (%lu bytes)" , ( unsigned long ) length ) ;
 info_ptr -> pcal_purpose = ( png_charp ) png_malloc_warn ( png_ptr , length ) ;
 if ( info_ptr -> pcal_purpose == NULL ) {
 png_warning ( png_ptr , "Insufficient memory for pCAL purpose." ) ;
 return ;
 }
 png_memcpy ( info_ptr -> pcal_purpose , purpose , ( png_size_t ) length ) ;
 png_debug ( 3 , "storing X0, X1, type, and nparams in info" ) ;
 info_ptr -> pcal_X0 = X0 ;
 info_ptr -> pcal_X1 = X1 ;
 info_ptr -> pcal_type = ( png_byte ) type ;
 info_ptr -> pcal_nparams = ( png_byte ) nparams ;
 length = png_strlen ( units ) + 1 ;
 png_debug1 ( 3 , "allocating units for info (%lu bytes)" , ( unsigned long ) length ) ;
 info_ptr -> pcal_units = ( png_charp ) png_malloc_warn ( png_ptr , length ) ;
 if ( info_ptr -> pcal_units == NULL ) {
 png_warning ( png_ptr , "Insufficient memory for pCAL units." ) ;
 return ;
 }
 png_memcpy ( info_ptr -> pcal_units , units , ( png_size_t ) length ) ;
 info_ptr -> pcal_params = ( png_charpp ) png_malloc_warn ( png_ptr , ( png_uint_32 ) ( ( nparams + 1 ) * png_sizeof ( png_charp ) ) ) ;
 if ( info_ptr -> pcal_params == NULL ) {
 png_warning ( png_ptr , "Insufficient memory for pCAL params." ) ;
 return ;
 }
 png_memset ( info_ptr -> pcal_params , 0 , ( nparams + 1 ) * png_sizeof ( png_charp ) ) ;
 for ( i = 0 ;
 i < nparams ;
 i ++ ) {
 length = png_strlen ( params [ i ] ) + 1 ;
 png_debug2 ( 3 , "allocating parameter %d for info (%lu bytes)" , i , ( unsigned long ) length ) ;
 info_ptr -> pcal_params [ i ] = ( png_charp ) png_malloc_warn ( png_ptr , length ) ;
 if ( info_ptr -> pcal_params [ i ] == NULL ) {
 png_warning ( png_ptr , "Insufficient memory for pCAL parameter." ) ;
 return ;
 }
 png_memcpy ( info_ptr -> pcal_params [ i ] , params [ i ] , ( png_size_t ) length ) ;
 }
 info_ptr -> valid |= PNG_INFO_pCAL ;
 # ifdef PNG_FREE_ME_SUPPORTED info_ptr -> free_me |= PNG_FREE_PCAL ;
 # endif }