two more small refleaks

introduced recently
This commit is contained in:
John Cupitt 2021-02-07 16:09:22 +00:00
parent 0296d7c154
commit 8b791a072e
2 changed files with 49 additions and 59 deletions

View File

@ -194,6 +194,10 @@ vips_foreign_load_ppm_dispose( GObject *gobject )
{
VipsForeignLoadPpm *ppm = (VipsForeignLoadPpm *) gobject;
#ifdef DEBUG
printf( "vips_foreign_load_ppm_dispose: %p\n", ppm );
#endif /*DEBUG*/
VIPS_UNREF( ppm->sbuf );
VIPS_UNREF( ppm->source );
@ -789,12 +793,9 @@ vips_foreign_load_ppm_file_build( VipsObject *object )
VipsForeignLoadPpmFile *file = (VipsForeignLoadPpmFile *) object;
VipsForeignLoadPpm *ppm = (VipsForeignLoadPpm *) object;
if( file->filename ) {
if( !(ppm->source =
vips_source_new_from_file( file->filename )) )
return( -1 );
ppm->sbuf = vips_sbuf_new_from_source( ppm->source );
}
if( file->filename &&
!(ppm->source = vips_source_new_from_file( file->filename )) )
return( -1 );
if( VIPS_OBJECT_CLASS( vips_foreign_load_ppm_file_parent_class )->
build( object ) )

View File

@ -212,13 +212,50 @@ vips_foreign_save_ppm_block( VipsRegion *region, VipsRect *area, void *a )
}
static int
vips_foreign_save_ppm( VipsForeignSavePpm *ppm, VipsImage *image )
vips_foreign_save_ppm_build( VipsObject *object )
{
VipsForeignSave *save = (VipsForeignSave *) ppm;
VipsForeignSave *save = (VipsForeignSave *) object;
VipsForeignSavePpm *ppm = (VipsForeignSavePpm *) object;
VipsImage *image;
char *magic;
char *date;
if( VIPS_OBJECT_CLASS( vips_foreign_save_ppm_parent_class )->
build( object ) )
return( -1 );
image = save->ready;
/* Handle the deprecated squash parameter.
*/
if( vips_object_argument_isset( object, "squash" ) )
ppm->bitdepth = 1;
if( vips_check_uintorf( "vips2ppm", image ) ||
vips_check_bands_1or3( "vips2ppm", image ) ||
vips_check_uncoded( "vips2ppm", image ) ||
vips_image_pio_input( image ) )
return( -1 );
if( ppm->ascii &&
image->BandFmt == VIPS_FORMAT_FLOAT ) {
g_warning( "%s",
_( "float images must be binary -- disabling ascii" ) );
ppm->ascii = FALSE;
}
/* One bit images must come from a 8 bit, one band source.
*/
if( ppm->bitdepth &&
(image->Bands != 1 ||
image->BandFmt != VIPS_FORMAT_UCHAR) ) {
g_warning( "%s",
_( "can only save 1 band uchar images as 1 bit -- "
"disabling 1 bit save" ) );
ppm->bitdepth = 0;
}
magic = "unset";
if( image->BandFmt == VIPS_FORMAT_FLOAT &&
image->Bands == 3 )
@ -317,9 +354,9 @@ vips_foreign_save_ppm( VipsForeignSavePpm *ppm, VipsImage *image )
return( -1 );
image = x;
/* image must now be unreffed on exit.
*/
vips_object_local( VIPS_OBJECT( ppm->target ), image );
/* image must now be unreffed on exit.
*/
vips_object_local( VIPS_OBJECT( ppm->target ), image );
}
if( vips_sink_disc( image, vips_foreign_save_ppm_block, ppm ) )
@ -330,54 +367,6 @@ vips_foreign_save_ppm( VipsForeignSavePpm *ppm, VipsImage *image )
return( 0 );
}
static int
vips_foreign_save_ppm_build( VipsObject *object )
{
VipsForeignSave *save = (VipsForeignSave *) object;
VipsForeignSavePpm *ppm = (VipsForeignSavePpm *) object;
VipsImage *image;
if( VIPS_OBJECT_CLASS( vips_foreign_save_ppm_parent_class )->
build( object ) )
return( -1 );
/* Handle the deprecated squash parameter.
*/
if( vips_object_argument_isset( object, "squash" ) )
ppm->bitdepth = 1;
image = save->ready;
if( vips_check_uintorf( "vips2ppm", image ) ||
vips_check_bands_1or3( "vips2ppm", image ) ||
vips_check_uncoded( "vips2ppm", image ) ||
vips_image_pio_input( image ) )
return( -1 );
if( ppm->ascii &&
image->BandFmt == VIPS_FORMAT_FLOAT ) {
g_warning( "%s",
_( "float images must be binary -- disabling ascii" ) );
ppm->ascii = FALSE;
}
/* One bit images must come from a 8 bit, one band source.
*/
if( ppm->bitdepth &&
(image->Bands != 1 ||
image->BandFmt != VIPS_FORMAT_UCHAR) ) {
g_warning( "%s",
_( "can only save 1 band uchar images as 1 bit -- "
"disabling 1 bit save" ) );
ppm->bitdepth = 0;
}
if( vips_foreign_save_ppm( ppm, image ) )
return( -1 );
return( 0 );
}
/* Save a bit of typing.
*/
#define UC VIPS_FORMAT_UCHAR