Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libvips/colour/profile_load.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ vips_profile_load_build( VipsObject *object )
else if( (data = vips__file_read_name( load->name,
vips__icc_dir(), &length )) )
profile = vips_blob_new(
(VipsCallbackFn) g_free, data, length );
(VipsCallbackFn) vips_area_free_cb, data, length );
else {
vips_error( class->nickname,
_( "unable to load profile \"%s\"" ), load->name );
Expand Down
24 changes: 24 additions & 0 deletions libvips/conversion/extract.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,14 @@ vips_extract_area_build( VipsObject *object )
return( 0 );
}

#ifdef __EMSCRIPTEN__
static void
vips_crop_class_init_adapter( VipsExtractAreaClass *class, void *dummy )
{
vips_extract_area_class_init( class );
}
#endif

static void
vips_extract_area_class_init( VipsExtractAreaClass *class )
{
Expand Down Expand Up @@ -226,6 +234,14 @@ vips_extract_area_class_init( VipsExtractAreaClass *class )

}

#ifdef __EMSCRIPTEN__
static void
vips_crop_init_adapter( VipsExtractArea *extract, void *dummy )
{
vips_extract_area_init( extract );
}
#endif

static void
vips_extract_area_init( VipsExtractArea *extract )
{
Expand Down Expand Up @@ -275,12 +291,20 @@ vips_crop_get_type( void )
sizeof( VipsExtractAreaClass ),
NULL, /* base_init */
NULL, /* base_finalize */
#ifdef __EMSCRIPTEN__
(GClassInitFunc) vips_crop_class_init_adapter,
#else
(GClassInitFunc) vips_extract_area_class_init,
#endif
NULL, /* class_finalize */
NULL, /* class_data */
sizeof( VipsExtractArea ),
32, /* n_preallocs */
#ifdef __EMSCRIPTEN__
(GInstanceInitFunc) vips_crop_init_adapter,
#else
(GInstanceInitFunc) vips_extract_area_init,
#endif
};

type = g_type_register_static( VIPS_TYPE_CONVERSION,
Expand Down
2 changes: 1 addition & 1 deletion libvips/conversion/tilecache.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ vips_tile_destroy( VipsTile *tile )

VIPS_UNREF( tile->region );

vips_free( tile );
g_free( tile );
}

static void
Expand Down
2 changes: 1 addition & 1 deletion libvips/convolution/canny.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ vips_canny_polar( VipsImage **args, VipsImage **out )
{
static GOnce once = G_ONCE_INIT;

g_once( &once, (GThreadFunc) vips_atan2_init, NULL );
g_once( &once, vips_atan2_init, NULL );

*out = vips_image_new();
if( vips_image_pipeline_array( *out,
Expand Down
2 changes: 1 addition & 1 deletion libvips/deprecated/package.c
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ im_free_vargv( im_function *fn, im_object *vargv )
/* If there is local storage, free it.
*/
if( fn->argv[i].desc->size != 0 )
vips_free( vargv[i] );
g_free( vargv[i] );

/* NULL out pointer.
*/
Expand Down
10 changes: 10 additions & 0 deletions libvips/deprecated/rename.c
Original file line number Diff line number Diff line change
Expand Up @@ -813,3 +813,13 @@ vips_autorot_get_angle( VipsImage *im )
return( VIPS_ANGLE_D0 );
}

/* The old vips_free(), now replaced by g_free() and vips_area_free_cb().
*/
int
vips_free( void *buf )
{
g_free( buf );

return( 0 );
}

10 changes: 5 additions & 5 deletions libvips/foreign/analyze2vips.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ read_header( const char *header )
if( len != sizeof( struct dsr ) ) {
vips_error( "analyze2vips",
"%s", _( "header file size incorrect" ) );
vips_free( d );
g_free( d );
return( NULL );
}

Expand Down Expand Up @@ -354,7 +354,7 @@ read_header( const char *header )
if( (int) len != d->hk.sizeof_hdr ) {
vips_error( "analyze2vips",
"%s", _( "header size incorrect" ) );
vips_free( d );
g_free( d );
return( NULL );
}

Expand Down Expand Up @@ -444,7 +444,7 @@ attach_meta( VipsImage *out, struct dsr *d )
int i;

vips_image_set_blob( out, "dsr",
(VipsCallbackFn) vips_free, d, d->hk.sizeof_hdr );
(VipsCallbackFn) vips_area_free_cb, d, d->hk.sizeof_hdr );

for( i = 0; i < VIPS_NUMBER( dsr_header ); i++ ) {
switch( dsr_header[i].type ) {
Expand Down Expand Up @@ -514,7 +514,7 @@ vips__isanalyze( const char *filename )
result = get_vips_properties( d, &width, &height, &bands, &fmt );
vips_error_thaw();

vips_free( d );
g_free( d );

return( result == 0 );
}
Expand All @@ -538,7 +538,7 @@ vips__analyze_read_header( const char *filename, VipsImage *out )
#endif /*DEBUG*/

if( get_vips_properties( d, &width, &height, &bands, &fmt ) ) {
vips_free( d );
g_free( d );
return( -1 );
}

Expand Down
4 changes: 2 additions & 2 deletions libvips/foreign/dzsave.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ vips_gsf_tree_new( GsfOutput *out, gint deflate_level )
}

static void *
vips_gsf_child_by_name_sub( VipsGsfDirectory *dir, const char *name )
vips_gsf_child_by_name_sub( VipsGsfDirectory *dir, const char *name, void *b )
{
if( strcmp( dir->name, name ) == 0 )
return( dir );
Expand Down Expand Up @@ -2692,7 +2692,7 @@ vips_foreign_save_dz_buffer_build( VipsObject *object )
gsf_output_memory_get_bytes( GSF_OUTPUT_MEMORY( dz->out ) ),
olen );

blob = vips_blob_new( (VipsCallbackFn) g_free, obuf, olen );
blob = vips_blob_new( (VipsCallbackFn) vips_area_free_cb, obuf, olen );
g_object_set( object, "buffer", blob, NULL );
vips_area_unref( VIPS_AREA( blob ) );

Expand Down
4 changes: 2 additions & 2 deletions libvips/foreign/exif.c
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,7 @@ vips_exif_exif_entry( ExifEntry *entry, VipsExifRemove *ve )
}

static void *
vips_exif_exif_remove( ExifEntry *entry, VipsExifRemove *ve )
vips_exif_exif_remove( ExifEntry *entry, VipsExifRemove *ve, void *b )
{
#ifdef DEBUG
{
Expand Down Expand Up @@ -1405,7 +1405,7 @@ vips__exif_update( VipsImage *image )
#endif /*DEBUG*/

vips_image_set_blob( image, VIPS_META_EXIF_NAME,
(VipsCallbackFn) vips_free, data, length );
(VipsCallbackFn) vips_area_free_cb, data, length );

exif_data_free( ed );

Expand Down
10 changes: 5 additions & 5 deletions libvips/foreign/foreign.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ file_add_class( VipsForeignClass *class, GSList **files )
}

static gint
file_compare( VipsForeignClass *a, VipsForeignClass *b )
file_compare( VipsForeignClass *a, VipsForeignClass *b, void *user_data )
{
return( b->priority - a->priority );
}
Expand Down Expand Up @@ -479,7 +479,7 @@ vips_foreign_load_summary_class( VipsObjectClass *object_class, VipsBuf *buf )
*/
static void *
vips_foreign_find_load_sub( VipsForeignLoadClass *load_class,
const char *filename )
const char *filename, void *b )
{
VipsObjectClass *object_class = VIPS_OBJECT_CLASS( load_class );
VipsForeignClass *class = VIPS_FOREIGN_CLASS( load_class );
Expand Down Expand Up @@ -1763,7 +1763,7 @@ vips_foreign_save_init( VipsForeignSave *save )
*/
static void *
vips_foreign_find_save_sub( VipsForeignSaveClass *save_class,
const char *filename )
const char *filename, void *b )
{
VipsObjectClass *object_class = VIPS_OBJECT_CLASS( save_class );
VipsForeignClass *class = VIPS_FOREIGN_CLASS( save_class );
Expand Down Expand Up @@ -1919,7 +1919,7 @@ vips_foreign_save( VipsImage *in, const char *name, ... )
*/
static void *
vips_foreign_find_save_target_sub( VipsForeignSaveClass *save_class,
const char *suffix )
const char *suffix, void *b )
{
VipsObjectClass *object_class = VIPS_OBJECT_CLASS( save_class );
VipsForeignClass *class = VIPS_FOREIGN_CLASS( save_class );
Expand Down Expand Up @@ -1977,7 +1977,7 @@ vips_foreign_find_save_target( const char *name )
*/
static void *
vips_foreign_find_save_buffer_sub( VipsForeignSaveClass *save_class,
const char *suffix )
const char *suffix, void *b )
{
VipsObjectClass *object_class = VIPS_OBJECT_CLASS( save_class );
VipsForeignClass *class = VIPS_FOREIGN_CLASS( save_class );
Expand Down
4 changes: 2 additions & 2 deletions libvips/foreign/jpeg2vips.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ readjpeg_free( ReadJpeg *jpeg )
}

static void
readjpeg_close_cb( VipsObject *object, ReadJpeg *jpeg )
readjpeg_close_cb( VipsImage *image, ReadJpeg *jpeg )
{
(void) readjpeg_free( jpeg );
}
Expand Down Expand Up @@ -728,7 +728,7 @@ read_jpeg_header( ReadJpeg *jpeg, VipsImage *out )
}

vips_image_set_blob( out, VIPS_META_ICC_NAME,
(VipsCallbackFn) vips_free, data, data_length );
(VipsCallbackFn) vips_area_free_cb, data, data_length );
}

return( 0 );
Expand Down
4 changes: 1 addition & 3 deletions libvips/foreign/magicksave.c
Original file line number Diff line number Diff line change
Expand Up @@ -593,9 +593,7 @@ vips_foreign_save_magick_buffer_build( VipsObject *object )
return( -1 );
}

/* obuf is a g_free() buffer, not vips_free().
*/
blob = vips_blob_new( (VipsCallbackFn) g_free, obuf, olen );
blob = vips_blob_new( (VipsCallbackFn) vips_area_free_cb, obuf, olen );
g_object_set( buffer, "buffer", blob, NULL );
vips_area_unref( VIPS_AREA( blob ) );

Expand Down
2 changes: 1 addition & 1 deletion libvips/foreign/matlab.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ read_destroy( Read *read )
VIPS_FREEF( Mat_VarFree, read->var );
VIPS_FREEF( Mat_Close, read->mat );

vips_free( read );
g_free( read );
}

static Read *
Expand Down
2 changes: 1 addition & 1 deletion libvips/foreign/openexr2vips.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ read_destroy( VipsImage *out, Read *read )

read_close( read );

vips_free( read );
g_free( read );
}

static Read *
Expand Down
6 changes: 3 additions & 3 deletions libvips/foreign/radiance.c
Original file line number Diff line number Diff line change
Expand Up @@ -739,13 +739,13 @@ vips__rad_israd( VipsSource *source )
}

static void
read_destroy( VipsObject *object, Read *read )
read_destroy( VipsImage *image, Read *read )
{
VIPS_UNREF( read->sbuf );
}

static void
read_minimise_cb( VipsObject *object, Read *read )
read_minimise_cb( VipsImage *image, Read *read )
{
if( read->sbuf )
vips_source_minimise( read->sbuf->source );
Expand Down Expand Up @@ -994,7 +994,7 @@ write_destroy( Write *write )
VIPS_FREE( write->line );
VIPS_UNREF( write->target );

vips_free( write );
g_free( write );
}

static Write *
Expand Down
4 changes: 2 additions & 2 deletions libvips/foreign/tiff2vips.c
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ rtiff_free( Rtiff *rtiff )
}

static void
rtiff_close_cb( VipsObject *object, Rtiff *rtiff )
rtiff_close_cb( VipsImage *image, Rtiff *rtiff )
{
rtiff_free( rtiff );
}
Expand Down Expand Up @@ -1926,7 +1926,7 @@ rtiff_fill_region( VipsRegion *out,
static int
rtiff_seq_stop( void *seq, void *a, void *b )
{
vips_free( seq );
g_free( seq );

return( 0 );
}
Expand Down
5 changes: 1 addition & 4 deletions libvips/foreign/tiffsave.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,10 +503,7 @@ vips_foreign_save_tiff_buffer_build( VipsObject *object )
tiff->subifd ) )
return( -1 );

/* vips__tiff_write_buf() makes a buffer that needs g_free(), not
* vips_free().
*/
blob = vips_blob_new( (VipsCallbackFn) g_free, obuf, olen );
blob = vips_blob_new( (VipsCallbackFn) vips_area_free_cb, obuf, olen );
g_object_set( object, "buffer", blob, NULL );
vips_area_unref( VIPS_AREA( blob ) );

Expand Down
8 changes: 4 additions & 4 deletions libvips/foreign/vips2tiff.c
Original file line number Diff line number Diff line change
Expand Up @@ -979,9 +979,9 @@ wtiff_free( Wtiff *wtiff )
wtiff_delete_temps( wtiff );

VIPS_UNREF( wtiff->ready );
VIPS_FREEF( vips_free, wtiff->tbuf );
VIPS_FREE( wtiff->tbuf );
VIPS_FREEF( layer_free_all, wtiff->layer );
VIPS_FREEF( vips_free, wtiff->icc_profile );
VIPS_FREE( wtiff->icc_profile );
VIPS_FREE( wtiff->filename );
VIPS_FREE( wtiff );
}
Expand Down Expand Up @@ -1888,11 +1888,11 @@ wtiff_copy_tiff( Wtiff *wtiff, TIFF *out, TIFF *in )
len = TIFFReadEncodedTile( in, tile, buf, -1 );
if( len < 0 ||
TIFFWriteEncodedTile( out, tile, buf, len ) < 0 ) {
vips_free( buf );
g_free( buf );
return( -1 );
}
}
vips_free( buf );
g_free( buf );

return( 0 );
}
Expand Down
4 changes: 4 additions & 0 deletions libvips/include/vips/almostdeprecated.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,10 @@ void vips_vinfo( const char *domain, const char *fmt, va_list ap );

VipsAngle vips_autorot_get_angle( VipsImage *image );

/* iofuncs
*/
int vips_free( void *buf );

#ifdef __cplusplus
}
#endif /*__cplusplus*/
Expand Down
Loading