diff --git a/TODO b/TODO index cbc44900..a082ccb5 100644 --- a/TODO +++ b/TODO @@ -5,9 +5,6 @@ #endif /*WITH_DMALLOC*/ -- (header -f height file.v) seems to segv? - - - do clip/embed etc. in new style, good to get everything that VipsAdd uses in the new stack diff --git a/libvips/deprecated/wrapvips7.c b/libvips/deprecated/wrapvips7.c index ed57d139..3ba82752 100644 --- a/libvips/deprecated/wrapvips7.c +++ b/libvips/deprecated/wrapvips7.c @@ -853,53 +853,3 @@ vips__init_wrap7_classes( void ) (void) im_map_packages( (VSListMap2Fn) vips_wrap7_build_package, NULL ); } -/* The vips7 malloc/free need to be thin wrappers over g_malloc()/g_free(), - * since we pass strings to and from the library and need to be able to free - * with either. - */ - -int -im_free( void *s ) -{ - g_free( s ); - - return( 0 ); -} - -void * -im_malloc( IMAGE *im, size_t size ) -{ - void *buf; - - if( !(buf = g_try_malloc( size )) ) { - im_error( "im_malloc", - _( "out of memory --- size == %dMB" ), - (int) (size / (1024.0*1024.0)) ); - im_warn( "im_malloc", - _( "out of memory --- size == %dMB" ), - (int) (size / (1024.0*1024.0)) ); - return( NULL ); - } - - if( im && im_add_close_callback( im, - (im_callback_fn) im_free, buf, NULL ) ) { - im_free( buf ); - return( NULL ); - } - - return( buf ); -} - -char * -im_strdup( IMAGE *im, const char *str ) -{ - int l = strlen( str ); - char *buf; - - if( !(buf = (char *) im_malloc( im, l + 1 )) ) - return( NULL ); - strcpy( buf, str ); - - return( buf ); -} - diff --git a/libvips/include/vips/memory.h b/libvips/include/vips/memory.h index 8f7efef8..da3f3b4c 100644 --- a/libvips/include/vips/memory.h +++ b/libvips/include/vips/memory.h @@ -65,7 +65,7 @@ G_STMT_START { \ ((T *) vips_malloc( VIPS_OBJECT( OBJ ), (N) * sizeof( T ))) void *vips_malloc( VipsObject *object, size_t size ); -char *vips_strdup( VipsObject *object, char *str ); +char *vips_strdup( VipsObject *object, const char *str ); int vips_free( void *buf ); void vips_tracked_free( void *s ); diff --git a/libvips/include/vips/vips7compat.h b/libvips/include/vips/vips7compat.h index 6451029f..d7e8437f 100644 --- a/libvips/include/vips/vips7compat.h +++ b/libvips/include/vips/vips7compat.h @@ -285,12 +285,6 @@ int im_generate( VipsImage *im, #define im__print_renders vips__print_renders #define im_cache vips_image_cache -/* vips_alloc() and friends are not the same, we need to keep these as C. - */ -char *im_strdup( IMAGE *im, const char *str ); -int im_free( void *s ); -void *im_malloc( IMAGE *im, size_t size ); - #define IM_FREEF( F, S ) \ G_STMT_START { \ if( S ) { \ @@ -323,6 +317,11 @@ G_STMT_START { \ } \ } G_STMT_END +#define im_malloc( IM, SZ ) \ + (vips_malloc( VIPS_OBJECT( IM ), (SZ) )) +#define im_free vips_free +#define im_strdup( IM, STR ) \ + (vips_strdup( VIPS_OBJECT( IM ), (STR) )) #define IM_NEW( IM, T ) ((T *) im_malloc( (IM), sizeof( T ))) #define IM_ARRAY( IM, N, T ) ((T *) im_malloc( (IM), (N) * sizeof( T ))) diff --git a/libvips/iofuncs/image.c b/libvips/iofuncs/image.c index 283886ae..ac8a1071 100644 --- a/libvips/iofuncs/image.c +++ b/libvips/iofuncs/image.c @@ -491,6 +491,7 @@ lazy_free_cb( VipsImage *image, Lazy *lazy ) g_free( lazy->filename ); VIPS_UNREF( lazy->real ); + g_free( lazy ); } static Lazy * diff --git a/libvips/iofuncs/memory.c b/libvips/iofuncs/memory.c index 690a57dd..95a1aeb4 100644 --- a/libvips/iofuncs/memory.c +++ b/libvips/iofuncs/memory.c @@ -171,7 +171,7 @@ vips_malloc( VipsObject *object, size_t size ) * Returns: a pointer to the allocated memory */ char * -vips_strdup( VipsObject *object, char *str ) +vips_strdup( VipsObject *object, const char *str ) { char *str_dup;