From fbc3b1f608c6062de3ae02e0c1bbb6a9e49987ca Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Fri, 23 Sep 2011 17:03:02 +0100 Subject: [PATCH] allow NULLs for output params so you can now do im_minpos (im, &min, NULL, NULL); --- TODO | 15 --------------- libvips/iofuncs/operation.c | 25 +++++++++++++++---------- 2 files changed, 15 insertions(+), 25 deletions(-) diff --git a/TODO b/TODO index e23ea94b..52838dad 100644 --- a/TODO +++ b/TODO @@ -1,18 +1,3 @@ -- strange - - $ vips avg babe.jpg - 222.370525 - $ vips im_avg babe.jpg - 222.371 - ** leak test on exit: - 3 objects alive: - 0) VipsAvg (0x1840df0) - 1) VipsImage (0x1844740) - 2) VipsImage (0x17b2d90) - - - - - get rid of useless DMALLOC stuff diff --git a/libvips/iofuncs/operation.c b/libvips/iofuncs/operation.c index d60f837b..3def51e9 100644 --- a/libvips/iofuncs/operation.c +++ b/libvips/iofuncs/operation.c @@ -446,18 +446,23 @@ vips_operation_get_valist_optional( VipsOperation *operation, va_list ap ) g_param_spec_get_name( pspec ), arg ); #endif /*VIPS_DEBUG */ - g_object_get( G_OBJECT( operation ), - g_param_spec_get_name( pspec ), arg, NULL ); - - /* If the pspec is an object, that will up the ref - * count. We want to hand over the ref, so we have to - * knock it down again. + /* If the dest pointer is NULL, skip the read. */ - if( G_IS_PARAM_SPEC_OBJECT( pspec ) ) { - GObject *object; + if( arg ) { + g_object_get( G_OBJECT( operation ), + g_param_spec_get_name( pspec ), arg, + NULL ); - object = *((GObject **) arg); - g_object_unref( object ); + /* If the pspec is an object, that will up + * the ref count. We want to hand over the + * ref, so we have to knock it down again. + */ + if( G_IS_PARAM_SPEC_OBJECT( pspec ) ) { + GObject *object; + + object = *((GObject **) arg); + g_object_unref( object ); + } } VIPS_OPERATION_COLLECT_END