diff --git a/ChangeLog b/ChangeLog index 873d23f8..da8305fb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -29,6 +29,7 @@ Warren and Nakilon - vector path for convolution is more accurate and can handle larger masks - linear and cubic kernels for reduce are higer quality +- added vips_value_set_blob_free() 29/8/17 started 8.5.9 - make --fail stop jpeg read on any libjpeg warning, thanks @mceachen diff --git a/libvips/include/vips/type.h b/libvips/include/vips/type.h index 88b44c88..8affd66a 100644 --- a/libvips/include/vips/type.h +++ b/libvips/include/vips/type.h @@ -223,6 +223,7 @@ void vips_value_set_ref_string( GValue *value, const char *str ); void *vips_value_get_blob( const GValue *value, size_t *length ); void vips_value_set_blob( GValue *value, VipsCallbackFn free_fn, void *data, size_t length ); +void vips_value_set_blob_free( GValue *value, void *data, size_t length ); void vips_value_set_array( GValue *value, int n, GType type, size_t sizeof_type ); diff --git a/libvips/iofuncs/type.c b/libvips/iofuncs/type.c index 76343984..3ed5be07 100644 --- a/libvips/iofuncs/type.c +++ b/libvips/iofuncs/type.c @@ -1558,6 +1558,32 @@ vips_value_set_blob( GValue *value, vips_area_unref( VIPS_AREA( blob ) ); } +/** + * vips_value_set_blob_free: + * @value: (out): GValue to set + * @data: pointer to area of memory + * @length: length of memory area + * + * Just like vips_value_set_blob(), but when + * @value is freed, @data will be + * freed with g_free(). + * + * This can be easier to call for language bindings. + * + * See also: vips_value_set_blob() + */ +void +vips_value_set_blob_free( GValue *value, void *data, size_t length ) +{ + VipsBlob *blob; + + g_assert( G_VALUE_TYPE( value ) == VIPS_TYPE_BLOB ); + + blob = vips_blob_new( g_free, data, length ); + g_value_set_boxed( value, blob ); + vips_area_unref( VIPS_AREA( blob ) ); +} + /** * vips_value_get_blob: * @value: GValue to set