add vips_value_set_blob_free()

simpler for language bindings to call
This commit is contained in:
John Cupitt 2017-10-19 16:37:43 +01:00
parent b060883706
commit dd503c03c6
3 changed files with 28 additions and 0 deletions

View File

@ -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

View File

@ -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 );

View File

@ -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