From 842d2e1b16e38da272cfc12338b701ffda640406 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Fri, 25 Mar 2011 14:01:12 +0000 Subject: [PATCH] more more stuff to vips_ window, memory, buffer, b64 all moved to the vips_ namespace --- libvips/include/vips/internal.h | 3 + libvips/include/vips/memory.h | 17 ++-- libvips/include/vips/private.h | 44 ++++----- libvips/include/vips/region.h | 4 +- libvips/include/vips/vips7compat.h | 4 + libvips/iofuncs/base64.c | 21 +++-- libvips/iofuncs/buffer.c | 138 ++++++++++++++--------------- libvips/iofuncs/dispatch_types.c | 18 ++-- libvips/iofuncs/generate.c | 2 +- libvips/iofuncs/image.c | 8 +- libvips/iofuncs/init.c | 2 +- libvips/iofuncs/memory.c | 43 ++++++--- libvips/iofuncs/meta.c | 20 ++--- libvips/iofuncs/package.c | 16 ++-- libvips/iofuncs/region.c | 16 ++-- libvips/iofuncs/sinkdisc.c | 2 +- libvips/iofuncs/sinkscreen.c | 4 +- libvips/iofuncs/util.c | 25 ++---- libvips/iofuncs/vips.c | 8 +- libvips/iofuncs/window.c | 64 ++++++------- 20 files changed, 235 insertions(+), 224 deletions(-) diff --git a/libvips/include/vips/internal.h b/libvips/include/vips/internal.h index d79dc7ae..2c55451a 100644 --- a/libvips/include/vips/internal.h +++ b/libvips/include/vips/internal.h @@ -190,6 +190,9 @@ struct im_col_tab_disp *im_col_make_tables_RGB( VipsImage *im, struct im_col_display *d ); struct im_col_tab_disp *im_col_display_get_table( struct im_col_display *d ); +char *vips__b64_encode( const unsigned char *data, size_t data_length ); +unsigned char *vips__b64_decode( const char *buffer, size_t *data_length ); + void *vips__mmap( int fd, int writeable, size_t length, gint64 offset ); int vips__munmap( void *start, size_t length ); int vips_mapfile( VipsImage * ); diff --git a/libvips/include/vips/memory.h b/libvips/include/vips/memory.h index 5165e848..8f7d1903 100644 --- a/libvips/include/vips/memory.h +++ b/libvips/include/vips/memory.h @@ -45,12 +45,12 @@ G_STMT_START { \ } G_STMT_END /* Can't just use VIPS_FREEF(), we want the extra cast to void on the argument - * to im_free() to make sure we can work for "const char *" variables. + * to vips_free() to make sure we can work for "const char *" variables. */ #define VIPS_FREE( S ) \ G_STMT_START { \ if( S ) { \ - (void) im_free( (void *) (S) ); \ + (void) vips_free( (void *) (S) ); \ (S) = 0; \ } \ } G_STMT_END @@ -63,17 +63,18 @@ G_STMT_START { \ if( !(S) || !sst || strcmp( (S), sst ) != 0 ) { \ VIPS_FREE( S ); \ if( sst ) \ - (S) = im_strdup( NULL, sst ); \ + (S) = vips_strdup( NULL, sst ); \ } \ } \ } G_STMT_END -#define VIPS_NEW( IM, T ) ((T *) im_malloc( (IM), sizeof( T ))) -#define VIPS_ARRAY( IM, N, T ) ((T *) im_malloc( (IM), (N) * sizeof( T ))) +#define VIPS_NEW( IM, T ) ((T *) vips_malloc( (IM), sizeof( T ))) +#define VIPS_ARRAY( IM, N, T ) ((T *) vips_malloc( (IM), (N) * sizeof( T ))) -void *im_malloc( VipsImage *im, size_t size ); -char *im_strdup( VipsImage *im, const char *str ); -int im_free( void *s ); +void *vips_malloc( VipsImage *image, size_t size ); +int vips_free( void *s ); + +char *vips_strdup( VipsImage *image, const char *str ); #ifdef __cplusplus } diff --git a/libvips/include/vips/private.h b/libvips/include/vips/private.h index 3876a7e9..e13fd453 100644 --- a/libvips/include/vips/private.h +++ b/libvips/include/vips/private.h @@ -70,54 +70,54 @@ typedef struct { PEL *baseaddr; /* Base of window */ size_t length; /* Size of window */ -} im_window_t; +} VipsWindow; /* window manager. */ -im_window_t *im_window_ref( struct _VipsImage *im, int top, int height ); -int im_window_unref( im_window_t *window ); -void im_window_print( im_window_t *window ); +VipsWindow *vips_window_ref( struct _VipsImage *im, int top, int height ); +int vips_window_unref( VipsWindow *window ); +void vips_window_print( VipsWindow *window ); /* Per-thread buffer cache. Held in a GPrivate. */ -typedef struct im__buffer_cache_t { - GHashTable *hash; /* Hash to im_buffer_cache_list_t* */ +typedef struct { + GHashTable *hash; /* Hash to VipsBufferCacheList* */ GThread *thread; /* Just for sanity checking */ -} im_buffer_cache_t; +} VipsBufferCache; -/* Per-image buffer cache. Hash to this from im_buffer_cache_t. +/* Per-image buffer cache. Hash to this from VipsBufferCache. * We can't store the GSList directly in the hash table, as GHashTable lacks an * update operation and we'd need to _remove() and _insert() on every list * operation. */ -typedef struct im__buffer_cache_list_t { - GSList *buffers; /* GSList of im_buffer_t* */ +typedef struct { + GSList *buffers; /* GSList of VipsBuffer* */ GThread *thread; /* Just for sanity checking */ struct _VipsImage *im; - im_buffer_cache_t *cache; -} im_buffer_cache_list_t; + VipsBufferCache *cache; +} VipsBufferCacheList; /* What we track for each pixel buffer. */ -typedef struct im__buffer_t { +typedef struct { int ref_count; /* # of regions referencing us */ struct _VipsImage *im; /* VipsImage we are attached to */ VipsRect area; /* Area this pixel buffer covers */ gboolean done; /* Calculated and in cache */ - im_buffer_cache_t *cache; + VipsBufferCache *cache; char *buf; /* Private malloc() area */ size_t bsize; /* Size of private malloc() */ -} im_buffer_t; +} VipsBuffer; -void im_buffer_done( im_buffer_t *buffer ); -void im_buffer_undone( im_buffer_t *buffer ); -void im_buffer_unref( im_buffer_t *buffer ); -im_buffer_t *im_buffer_new( struct _VipsImage *im, VipsRect *area ); -im_buffer_t *im_buffer_ref( struct _VipsImage *im, VipsRect *area ); -im_buffer_t *im_buffer_unref_ref( im_buffer_t *buffer, +void vips_buffer_done( VipsBuffer *buffer ); +void vips_buffer_undone( VipsBuffer *buffer ); +void vips_buffer_unref( VipsBuffer *buffer ); +VipsBuffer *vips_buffer_new( struct _VipsImage *im, VipsRect *area ); +VipsBuffer *vips_buffer_ref( struct _VipsImage *im, VipsRect *area ); +VipsBuffer *vips_buffer_unref_ref( VipsBuffer *buffer, struct _VipsImage *im, VipsRect *area ); -void im_buffer_print( im_buffer_t *buffer ); +void vips_buffer_print( VipsBuffer *buffer ); /* Sections of region.h that are private to VIPS. */ diff --git a/libvips/include/vips/region.h b/libvips/include/vips/region.h index c189384a8..c465359c 100644 --- a/libvips/include/vips/region.h +++ b/libvips/include/vips/region.h @@ -80,11 +80,11 @@ typedef struct _VipsRegion { /* Ref to the window we use for this region, if any. */ - im_window_t *window; + VipsWindow *window; /* Ref to the buffer we use for this region, if any. */ - im_buffer_t *buffer; + VipsBuffer *buffer; /* The image this region is on has changed and caches need to be * dropped. diff --git a/libvips/include/vips/vips7compat.h b/libvips/include/vips/vips7compat.h index 03888f9f..b2c7ffc2 100644 --- a/libvips/include/vips/vips7compat.h +++ b/libvips/include/vips/vips7compat.h @@ -303,6 +303,10 @@ VipsDemandStyle im_char2dhint( const char *str ); #define im__print_renders vips__print_renders #define im_cache vips_image_cache +#define im_malloc vips_malloc +#define im_free vips_free +#define im_strdup vips_strdup + /* Buffer processing. */ typedef void (*im_wrapone_fn)( void *in, void *out, int width, diff --git a/libvips/iofuncs/base64.c b/libvips/iofuncs/base64.c index b04481ce..c7b6d87f 100644 --- a/libvips/iofuncs/base64.c +++ b/libvips/iofuncs/base64.c @@ -62,6 +62,9 @@ Modified on: 12/5/09 - fix signed/unsigned warning +25/3/11 + - move to vips_ namespace + */ /* @@ -155,7 +158,7 @@ encode24( char *p, int bits, size_t remaining ) * rather than quick. */ char * -im__b64_encode( const unsigned char *data, size_t data_length ) +vips__b64_encode( const unsigned char *data, size_t data_length ) { /* Worst case: 1.333 chars per byte, plus 10% for extra carriage * returns and stuff. And the \n\0 at the end. @@ -168,16 +171,16 @@ im__b64_encode( const unsigned char *data, size_t data_length ) int cursor; if( data_length <= 0 ) { - vips_error( "im__b64_encode", "%s", _( "too little data" ) ); + vips_error( "vips__b64_encode", "%s", _( "too little data" ) ); return( NULL ); } if( output_data_length > 1024 * 1024 ) { /* We shouldn't really be used for large amounts of data. */ - vips_error( "im__b64_encode", "%s", _( "too much data" ) ); + vips_error( "vips__b64_encode", "%s", _( "too much data" ) ); return( NULL ); } - if( !(buffer = im_malloc( NULL, output_data_length )) ) + if( !(buffer = vips_malloc( NULL, output_data_length )) ) return( NULL ); p = buffer; @@ -211,7 +214,7 @@ im__b64_encode( const unsigned char *data, size_t data_length ) for( total = 0, i = 0; i < data_length; i++ ) total += data[i]; - printf( "im__b64_encode: length = %d, checksum 0x%x\n", + printf( "vips__b64_encode: length = %d, checksum 0x%x\n", data_length, total & 0xffff ); } #endif /*DEBUG*/ @@ -222,7 +225,7 @@ im__b64_encode( const unsigned char *data, size_t data_length ) /* Decode base64 back to binary in a malloc'd buffer. NULL on error. */ unsigned char * -im__b64_decode( const char *buffer, size_t *data_length ) +vips__b64_decode( const char *buffer, size_t *data_length ) { const size_t buffer_length = strlen( buffer ); @@ -239,11 +242,11 @@ im__b64_decode( const char *buffer, size_t *data_length ) if( output_data_length > 1024 * 1024 ) { /* We shouldn't really be used for large amounts of data. */ - vips_error( "im__b64_decode", "%s", _( "too much data" ) ); + vips_error( "vips__b64_decode", "%s", _( "too much data" ) ); return( NULL ); } - if( !(data = im_malloc( NULL, output_data_length )) ) + if( !(data = vips_malloc( NULL, output_data_length )) ) return( NULL ); p = data; @@ -279,7 +282,7 @@ im__b64_decode( const char *buffer, size_t *data_length ) for( total = 0, i = 0; i < p - data; i++ ) total += data[i]; - printf( "im__b64_decode: length = %d, checksum 0x%x\n", + printf( "vips__b64_decode: length = %d, checksum 0x%x\n", p - data, total & 0xffff ); } #endif /*DEBUG*/ diff --git a/libvips/iofuncs/buffer.c b/libvips/iofuncs/buffer.c index d0cae86f..affe4f34 100644 --- a/libvips/iofuncs/buffer.c +++ b/libvips/iofuncs/buffer.c @@ -10,7 +10,7 @@ * - split to a buffer hash per thread * - reuse buffer mallocs when we can * 20/2/07 - * - add im_buffer_cache_list_t and we can avoid some hash ops on + * - add VipsBufferCacheList and we can avoid some hash ops on * done/undone * 5/3/10 * - move invalid stuff to region @@ -67,7 +67,7 @@ #ifdef DEBUG /* Track all regions here for debugging. */ -static GSList *im__buffers_all = NULL; +static GSList *vips__buffers_all = NULL; #endif /*DEBUG*/ #ifdef DEBUG_CREATE @@ -77,14 +77,14 @@ static int buffer_cache_n = 0; #ifdef HAVE_THREADS static GPrivate *thread_buffer_cache_key = NULL; #else /*!HAVE_THREADS*/ -static im_buffer_cache_t *thread_buffer_cache = NULL; +static VipsBufferCache *thread_buffer_cache = NULL; #endif /*HAVE_THREADS*/ /* Only need this if we're threading and need to do a lot of start/stop. */ #ifdef HAVE_THREADS static void -buffer_cache_free( im_buffer_cache_t *cache ) +buffer_cache_free( VipsBufferCache *cache ) { #ifdef DEBUG_CREATE buffer_cache_n -= 1; @@ -100,7 +100,7 @@ buffer_cache_free( im_buffer_cache_t *cache ) #endif /*HAVE_THREADS*/ static void -buffer_cache_list_free( im_buffer_cache_list_t *cache_list ) +buffer_cache_list_free( VipsBufferCacheList *cache_list ) { GSList *p; @@ -108,21 +108,21 @@ buffer_cache_list_free( im_buffer_cache_list_t *cache_list ) * unref. */ for( p = cache_list->buffers; p; p = p->next ) { - im_buffer_t *buffer = (im_buffer_t *) p->data; + VipsBuffer *buffer = (VipsBuffer *) p->data; buffer->done = FALSE; } g_slist_free( cache_list->buffers ); - im_free( cache_list ); + vips_free( cache_list ); } -static im_buffer_cache_list_t * -buffer_cache_list_new( im_buffer_cache_t *cache, IMAGE *im ) +static VipsBufferCacheList * +buffer_cache_list_new( VipsBufferCache *cache, VipsImage *im ) { - im_buffer_cache_list_t *cache_list; + VipsBufferCacheList *cache_list; - if( !(cache_list = VIPS_NEW( NULL, im_buffer_cache_list_t )) ) + if( !(cache_list = VIPS_NEW( NULL, VipsBufferCacheList )) ) return( NULL ); cache_list->buffers = NULL; cache_list->thread = g_thread_self(); @@ -138,12 +138,12 @@ buffer_cache_list_new( im_buffer_cache_t *cache, IMAGE *im ) return( cache_list ); } -static im_buffer_cache_t * +static VipsBufferCache * buffer_cache_new( void ) { - im_buffer_cache_t *cache; + VipsBufferCache *cache; - if( !(cache = VIPS_NEW( NULL, im_buffer_cache_t )) ) + if( !(cache = VIPS_NEW( NULL, VipsBufferCache )) ) return( NULL ); cache->hash = g_hash_table_new_full( g_direct_hash, g_direct_equal, @@ -163,10 +163,10 @@ buffer_cache_new( void ) /* Get the buffer cache. */ -static im_buffer_cache_t * +static VipsBufferCache * buffer_cache_get( void ) { - im_buffer_cache_t *cache; + VipsBufferCache *cache; #ifdef HAVE_THREADS if( !(cache = g_private_get( thread_buffer_cache_key )) ) { @@ -185,17 +185,17 @@ buffer_cache_get( void ) /* Pixels have been calculated: publish for other parts of this thread to see. */ void -im_buffer_done( im_buffer_t *buffer ) +vips_buffer_done( VipsBuffer *buffer ) { if( !buffer->done ) { - IMAGE *im = buffer->im; - im_buffer_cache_t *cache = buffer_cache_get(); - im_buffer_cache_list_t *cache_list; + VipsImage *im = buffer->im; + VipsBufferCache *cache = buffer_cache_get(); + VipsBufferCacheList *cache_list; #ifdef DEBUG - printf( "im_buffer_done: thread %p adding to cache %p\n", + printf( "vips_buffer_done: thread %p adding to cache %p\n", g_thread_self(), cache ); - im_buffer_print( buffer ); + vips_buffer_print( buffer ); #endif /*DEBUG*/ /* Look up and update the buffer list. @@ -218,15 +218,15 @@ im_buffer_done( im_buffer_t *buffer ) /* Take off the public 'done' list. */ void -im_buffer_undone( im_buffer_t *buffer ) +vips_buffer_undone( VipsBuffer *buffer ) { if( buffer->done ) { - IMAGE *im = buffer->im; - im_buffer_cache_t *cache = buffer->cache; - im_buffer_cache_list_t *cache_list; + VipsImage *im = buffer->im; + VipsBufferCache *cache = buffer->cache; + VipsBufferCacheList *cache_list; #ifdef DEBUG - printf( "im_buffer_undone: thread %p removing " + printf( "vips_buffer_undone: thread %p removing " "buffer %p from cache %p\n", g_thread_self(), buffer, cache ); #endif /*DEBUG*/ @@ -245,17 +245,17 @@ im_buffer_undone( im_buffer_t *buffer ) buffer->cache = NULL; #ifdef DEBUG - printf( "im_buffer_undone: %d buffers left\n", + printf( "vips_buffer_undone: %d buffers left\n", g_slist_length( cache_list->buffers ) ); #endif /*DEBUG*/ } } void -im_buffer_unref( im_buffer_t *buffer ) +vips_buffer_unref( VipsBuffer *buffer ) { #ifdef DEBUG - printf( "** im_buffer_unref: left = %d, top = %d, " + printf( "** vips_buffer_unref: left = %d, top = %d, " "width = %d, height = %d (%p)\n", buffer->area.left, buffer->area.top, buffer->area.width, buffer->area.height, @@ -269,22 +269,22 @@ im_buffer_unref( im_buffer_t *buffer ) if( buffer->ref_count == 0 ) { #ifdef DEBUG if( !buffer->done ) - printf( "im_buffer_unref: buffer was not done\n" ); + printf( "vips_buffer_unref: buffer was not done\n" ); #endif /*DEBUG*/ - im_buffer_undone( buffer ); + vips_buffer_undone( buffer ); buffer->im = NULL; VIPS_FREE( buffer->buf ); buffer->bsize = 0; - im_free( buffer ); + vips_free( buffer ); #ifdef DEBUG g_mutex_lock( vips__global_lock ); - g_assert( g_slist_find( im__buffers_all, buffer ) ); - im__buffers_all = g_slist_remove( im__buffers_all, buffer ); + g_assert( g_slist_find( vips__buffers_all, buffer ) ); + vips__buffers_all = g_slist_remove( vips__buffers_all, buffer ); printf( "%d buffers in vips\n", - g_slist_length( im__buffers_all ) ); + g_slist_length( vips__buffers_all ) ); g_mutex_unlock( vips__global_lock ); #endif /*DEBUG*/ } @@ -292,12 +292,12 @@ im_buffer_unref( im_buffer_t *buffer ) /* Make a new buffer. */ -im_buffer_t * -im_buffer_new( IMAGE *im, VipsRect *area ) +VipsBuffer * +vips_buffer_new( VipsImage *im, VipsRect *area ) { - im_buffer_t *buffer; + VipsBuffer *buffer; - if( !(buffer = VIPS_NEW( NULL, im_buffer_t )) ) + if( !(buffer = VIPS_NEW( NULL, VipsBuffer )) ) return( NULL ); buffer->ref_count = 1; @@ -307,13 +307,13 @@ im_buffer_new( IMAGE *im, VipsRect *area ) buffer->cache = NULL; buffer->bsize = (size_t) VIPS_IMAGE_SIZEOF_PEL( im ) * area->width * area->height; - if( !(buffer->buf = im_malloc( NULL, buffer->bsize )) ) { - im_buffer_unref( buffer ); + if( !(buffer->buf = vips_malloc( NULL, buffer->bsize )) ) { + vips_buffer_unref( buffer ); return( NULL ); } #ifdef DEBUG - printf( "** im_buffer_new: left = %d, top = %d, " + printf( "** vips_buffer_new: left = %d, top = %d, " "width = %d, height = %d (%p)\n", buffer->area.left, buffer->area.top, buffer->area.width, buffer->area.height, @@ -322,8 +322,8 @@ im_buffer_new( IMAGE *im, VipsRect *area ) #ifdef DEBUG g_mutex_lock( vips__global_lock ); - im__buffers_all = g_slist_prepend( im__buffers_all, buffer ); - printf( "%d buffers in vips\n", g_slist_length( im__buffers_all ) ); + vips__buffers_all = g_slist_prepend( vips__buffers_all, buffer ); + printf( "%d buffers in vips\n", g_slist_length( vips__buffers_all ) ); g_mutex_unlock( vips__global_lock ); #endif /*DEBUG*/ @@ -331,15 +331,15 @@ im_buffer_new( IMAGE *im, VipsRect *area ) } static int -buffer_move( im_buffer_t *buffer, VipsRect *area ) +buffer_move( VipsBuffer *buffer, VipsRect *area ) { - IMAGE *im = buffer->im; + VipsImage *im = buffer->im; size_t new_bsize; g_assert( buffer->ref_count == 1 ); buffer->area = *area; - im_buffer_undone( buffer ); + vips_buffer_undone( buffer ); g_assert( !buffer->done ); new_bsize = (size_t) VIPS_IMAGE_SIZEOF_PEL( im ) * @@ -347,7 +347,7 @@ buffer_move( im_buffer_t *buffer, VipsRect *area ) if( buffer->bsize < new_bsize ) { buffer->bsize = new_bsize; VIPS_FREE( buffer->buf ); - if( !(buffer->buf = im_malloc( NULL, buffer->bsize )) ) + if( !(buffer->buf = vips_malloc( NULL, buffer->bsize )) ) return( -1 ); } @@ -356,12 +356,12 @@ buffer_move( im_buffer_t *buffer, VipsRect *area ) /* Find an existing buffer that encloses area and return a ref. */ -static im_buffer_t * -buffer_find( IMAGE *im, VipsRect *r ) +static VipsBuffer * +buffer_find( VipsImage *im, VipsRect *r ) { - im_buffer_cache_t *cache = buffer_cache_get(); - im_buffer_cache_list_t *cache_list; - im_buffer_t *buffer; + VipsBufferCache *cache = buffer_cache_get(); + VipsBufferCacheList *cache_list; + VipsBuffer *buffer; GSList *p; VipsRect *area; @@ -375,7 +375,7 @@ buffer_find( IMAGE *im, VipsRect *r ) * search for the largest? */ for( ; p; p = p->next ) { - buffer = (im_buffer_t *) p->data; + buffer = (VipsBuffer *) p->data; area = &buffer->area; if( area->left <= r->left && @@ -385,7 +385,7 @@ buffer_find( IMAGE *im, VipsRect *r ) buffer->ref_count += 1; #ifdef DEBUG - printf( "im_buffer_find: left = %d, top = %d, " + printf( "vips_buffer_find: left = %d, top = %d, " "width = %d, height = %d, count = %d (%p)\n", buffer->area.left, buffer->area.top, buffer->area.width, buffer->area.height, @@ -405,15 +405,15 @@ buffer_find( IMAGE *im, VipsRect *r ) /* Return a ref to a buffer that encloses area. */ -im_buffer_t * -im_buffer_ref( IMAGE *im, VipsRect *area ) +VipsBuffer * +vips_buffer_ref( VipsImage *im, VipsRect *area ) { - im_buffer_t *buffer; + VipsBuffer *buffer; if( !(buffer = buffer_find( im, area )) ) /* No existing buffer ... make a new one. */ - if( !(buffer = im_buffer_new( im, area )) ) + if( !(buffer = vips_buffer_new( im, area )) ) return( NULL ); return( buffer ); @@ -422,10 +422,10 @@ im_buffer_ref( IMAGE *im, VipsRect *area ) /* Unref old, ref new, in a single operation. Reuse stuff if we can. The * buffer we return might or might not be done. */ -im_buffer_t * -im_buffer_unref_ref( im_buffer_t *old_buffer, IMAGE *im, VipsRect *area ) +VipsBuffer * +vips_buffer_unref_ref( VipsBuffer *old_buffer, VipsImage *im, VipsRect *area ) { - im_buffer_t *buffer; + VipsBuffer *buffer; g_assert( !old_buffer || old_buffer->im == im ); @@ -438,7 +438,7 @@ im_buffer_unref_ref( im_buffer_t *old_buffer, IMAGE *im, VipsRect *area ) /* Does the new area already have a buffer? */ if( (buffer = buffer_find( im, area )) ) { - VIPS_FREEF( im_buffer_unref, old_buffer ); + VIPS_FREEF( vips_buffer_unref, old_buffer ); return( buffer ); } @@ -446,7 +446,7 @@ im_buffer_unref_ref( im_buffer_t *old_buffer, IMAGE *im, VipsRect *area ) */ if( old_buffer && old_buffer->ref_count == 1 ) { if( buffer_move( old_buffer, area ) ) { - im_buffer_unref( old_buffer ); + vips_buffer_unref( old_buffer ); return( NULL ); } @@ -455,17 +455,17 @@ im_buffer_unref_ref( im_buffer_t *old_buffer, IMAGE *im, VipsRect *area ) /* Fallback ... unref the old one, make a new one. */ - VIPS_FREEF( im_buffer_unref, old_buffer ); - if( !(buffer = im_buffer_new( im, area )) ) + VIPS_FREEF( vips_buffer_unref, old_buffer ); + if( !(buffer = vips_buffer_new( im, area )) ) return( NULL ); return( buffer ); } void -im_buffer_print( im_buffer_t *buffer ) +vips_buffer_print( VipsBuffer *buffer ) { - printf( "im_buffer_t: %p ref_count = %d, ", buffer, buffer->ref_count ); + printf( "VipsBuffer: %p ref_count = %d, ", buffer, buffer->ref_count ); printf( "im = %p, ", buffer->im ); printf( "area.left = %d, ", buffer->area.left ); printf( "area.top = %d, ", buffer->area.top ); diff --git a/libvips/iofuncs/dispatch_types.c b/libvips/iofuncs/dispatch_types.c index 3b0b6b13..5f56e28a 100644 --- a/libvips/iofuncs/dispatch_types.c +++ b/libvips/iofuncs/dispatch_types.c @@ -182,7 +182,7 @@ imagevec_dest( im_object obj ) iv->vec[i] = NULL; } - im_free( iv->vec ); + vips_free( iv->vec ); iv->vec = NULL; iv->n = 0; } @@ -245,7 +245,7 @@ mask_init( im_object *obj, char *str ) /* Install string, clear mask. */ - if( str && !(mo->name = im_strdup( NULL, str )) ) + if( str && !(mo->name = vips_strdup( NULL, str )) ) return( -1 ); mo->mask = NULL; @@ -290,7 +290,7 @@ dmask_dest( im_object obj ) im_mask_object *mo = obj; if( mo->name ) { - im_free( mo->name ); + vips_free( mo->name ); mo->name = NULL; } if( mo->mask ) { @@ -309,7 +309,7 @@ imask_dest( im_object obj ) im_mask_object *mo = obj; if( mo->name ) { - im_free( mo->name ); + vips_free( mo->name ); mo->name = NULL; } if( mo->mask ) { @@ -425,7 +425,7 @@ doublevec_dest( im_object obj ) im_doublevec_object *dv = obj; if( dv->vec ) { - im_free( dv->vec ); + vips_free( dv->vec ); dv->vec = NULL; dv->n = 0; } @@ -510,7 +510,7 @@ intvec_dest( im_object obj ) im_intvec_object *iv = obj; if( iv->vec ) { - im_free( iv->vec ); + vips_free( iv->vec ); iv->vec = NULL; iv->n = 0; } @@ -623,7 +623,7 @@ im_type_desc im__input_int = { static int input_string_init( im_object *obj, char *str ) { - if( !(*obj = (im_object) im_strdup( NULL, str )) ) + if( !(*obj = (im_object) vips_strdup( NULL, str )) ) return( -1 ); return( 0 ); @@ -636,7 +636,7 @@ im_type_desc im__input_string = { 0, /* Memory to allocate */ IM_TYPE_ARG, /* It requires a command-line arg */ input_string_init, /* Init function */ - im_free /* Destroy function */ + vips_free /* Destroy function */ }; /* Output string type. @@ -646,7 +646,7 @@ im_type_desc im__output_string = { 0, /* Memory to allocate */ IM_TYPE_OUTPUT, /* It's an output argument */ NULL, /* Init function */ - im_free /* Destroy function */ + vips_free /* Destroy function */ }; /* Output double type. diff --git a/libvips/iofuncs/generate.c b/libvips/iofuncs/generate.c index 9cecf14b..7da0dcd3 100644 --- a/libvips/iofuncs/generate.c +++ b/libvips/iofuncs/generate.c @@ -416,7 +416,7 @@ vips_stop_many( void *seq, void *a, void *b ) for( i = 0; ar[i]; i++ ) g_object_unref( ar[i] ); - im_free( (char *) ar ); + vips_free( (char *) ar ); } return( 0 ); diff --git a/libvips/iofuncs/image.c b/libvips/iofuncs/image.c index 7e69221d..9aae3aa8 100644 --- a/libvips/iofuncs/image.c +++ b/libvips/iofuncs/image.c @@ -398,7 +398,7 @@ vips_image_finalize( GObject *gobject ) if( image->dtype == VIPS_IMAGE_SETBUF ) { VIPS_DEBUG_MSG( "vips_image_finalize: " "freeing buffer\n" ); - im_free( image->data ); + vips_free( image->data ); image->dtype = VIPS_IMAGE_NONE; } @@ -608,7 +608,7 @@ lazy_new( VipsImage *image, lazy->real = NULL; g_signal_connect( image, "close", G_CALLBACK( lazy_free_cb ), NULL ); - if( !(lazy->filename = im_strdup( NULL, filename )) ) + if( !(lazy->filename = vips_strdup( NULL, filename )) ) return( NULL ); return( lazy ); @@ -819,7 +819,7 @@ vips_attach_save( VipsImage *image, int (*save_fn)(), const char *filename ) if( (sb = VIPS_NEW( image, SaveBlock )) ) { sb->save_fn = save_fn; - sb->filename = im_strdup( image, filename ); + sb->filename = vips_strdup( image, filename ); g_signal_connect( image, "written", G_CALLBACK( vips_image_save_cb ), sb ); } @@ -1841,7 +1841,7 @@ vips__image_write_prepare( VipsImage *image ) /* Allocate memory. */ if( !image->data ) - if( !(image->data = im_malloc( NULL, + if( !(image->data = vips_malloc( NULL, VIPS_IMAGE_SIZEOF_IMAGE( image ))) ) return( -1 ); diff --git a/libvips/iofuncs/init.c b/libvips/iofuncs/init.c index 92501d23..9f3110c1 100644 --- a/libvips/iofuncs/init.c +++ b/libvips/iofuncs/init.c @@ -449,7 +449,7 @@ extract_prefix( const char *dir, const char *name ) printf( "extract_prefix: found \"%s\"\n", vname ); #endif /*DEBUG*/ - return( im_strdup( NULL, vname ) ); + return( vips_strdup( NULL, vname ) ); } /* Search a path for a file ... we overwrite the PATH string passed in. diff --git a/libvips/iofuncs/memory.c b/libvips/iofuncs/memory.c index 331ebf47..a87d9077 100644 --- a/libvips/iofuncs/memory.c +++ b/libvips/iofuncs/memory.c @@ -104,7 +104,7 @@ static int next_trace = 0; #endif /*DEBUGM*/ /** - * IM_NEW: + * VIPS_NEW: * @IM: allocate memory local to @IM, or %NULL for no auto-free * @T: type of thing to allocate * @@ -112,7 +112,7 @@ static int next_trace = 0; */ /** - * IM_ARRAY: + * VIPS_ARRAY: * @IM: allocate memory local to @IM, or %NULL for no auto-free * @N: number of @T 's to allocate * @T: type of thing to allocate @@ -121,20 +121,20 @@ static int next_trace = 0; */ /** - * im_free: + * vips_free: * @s: memory to free * * VIPS free function. VIPS tries to use this instead of free(). It always * returns zero, so it can be used as a callback handler. * * Only use it to free - * memory that was previously allocated with im_malloc() with a %NULL first + * memory that was previously allocated with vips_malloc() with a %NULL first * argument. * * Returns: 0 */ int -im_free( void *s ) +vips_free( void *s ) { #ifdef DEBUGM { @@ -179,14 +179,14 @@ im_free( void *s ) } static void -im_malloc_cb( VipsImage *image, char *buf ) +vips_malloc_cb( VipsImage *image, char *buf ) { - im_free( buf ); + vips_free( buf ); } /** - * im_malloc: - * @im: allocate memory local to this #IMAGE, or %NULL + * vips_malloc: + * @image: allocate memory local to this #VipsImage, or %NULL * @size: number of bytes to allocate * * Malloc local to @im, that is, the memory will be automatically @@ -201,7 +201,7 @@ im_malloc_cb( VipsImage *image, char *buf ) * Returns: a pointer to the allocated memory, or %NULL on error. */ void * -im_malloc( IMAGE *im, size_t size ) +vips_malloc( VipsImage *image, size_t size ) { void *buf; @@ -249,7 +249,7 @@ im_malloc( IMAGE *im, size_t size ) next_trace += 1; if( next_trace > trace_freq ) { - printf( "im_malloc: %d, %d allocs, total %.3gM, " + printf( "vips_malloc: %d, %d allocs, total %.3gM, " "high water %.3gM\n", size, total_allocs, @@ -266,9 +266,24 @@ im_malloc( IMAGE *im, size_t size ) printf( "woah! big!\n" ); #endif /*DEBUGM*/ - if( im ) - g_signal_connect( im, "close", - G_CALLBACK( im_malloc_cb ), buf ); + if( image ) + g_signal_connect( image, "close", + G_CALLBACK( vips_malloc_cb ), buf ); return( buf ); } + +/* strdup local to a descriptor. + */ +char * +vips_strdup( VipsImage *image, const char *str ) +{ + int l = strlen( str ); + char *buf; + + if( !(buf = (char *) vips_malloc( image, l + 1 )) ) + return( NULL ); + strcpy( buf, str ); + + return( buf ); +} diff --git a/libvips/iofuncs/meta.c b/libvips/iofuncs/meta.c index 52fa0406..70b3f915 100644 --- a/libvips/iofuncs/meta.c +++ b/libvips/iofuncs/meta.c @@ -198,7 +198,7 @@ meta_free( Meta *meta ) g_value_unset( &meta->value ); VIPS_FREE( meta->field ); - im_free( meta ); + vips_free( meta ); } static Meta * @@ -212,7 +212,7 @@ meta_new( IMAGE *im, const char *field, GValue *value ) meta->field = NULL; memset( &meta->value, 0, sizeof( GValue ) ); - if( !(meta->field = im_strdup( NULL, field )) ) { + if( !(meta->field = vips_strdup( NULL, field )) ) { meta_free( meta ); return( NULL ); } @@ -782,7 +782,7 @@ area_unref( Area *area ) if( area->count == 0 && area->free_fn ) { (void) area->free_fn( area->data, NULL ); area->free_fn = NULL; - im_free( area ); + vips_free( area ); #ifdef DEBUG area_number -= 1; @@ -964,10 +964,10 @@ im_ref_string_set( GValue *value, const char *str ) g_assert( G_VALUE_TYPE( value ) == IM_TYPE_REF_STRING ); - if( !(str_copy = im_strdup( NULL, str )) ) + if( !(str_copy = vips_strdup( NULL, str )) ) return( -1 ); - if( !(area = area_new( (im_callback_fn) im_free, str_copy )) ) { - im_free( str_copy ); + if( !(area = area_new( (im_callback_fn) vips_free, str_copy )) ) { + vips_free( str_copy ); return( -1 ); } @@ -1141,9 +1141,9 @@ transform_blob_save_string( const GValue *src_value, GValue *dest_value ) char *b64; blob = im_blob_get( src_value, &blob_length ); - if( (b64 = im__b64_encode( blob, blob_length )) ) { + if( (b64 = vips__b64_encode( blob, blob_length )) ) { im_save_string_set( dest_value, b64 ); - im_free( b64 ); + vips_free( b64 ); } } @@ -1155,9 +1155,9 @@ transform_save_string_blob( const GValue *src_value, GValue *dest_value ) size_t blob_length; b64 = im_save_string_get( src_value ); - if( (blob = im__b64_decode( b64, &blob_length )) ) + if( (blob = vips__b64_decode( b64, &blob_length )) ) im_blob_set( dest_value, - (im_callback_fn) im_free, blob, blob_length ); + (im_callback_fn) vips_free, blob, blob_length ); } GType diff --git a/libvips/iofuncs/package.c b/libvips/iofuncs/package.c index 2b712655..697b9b00 100644 --- a/libvips/iofuncs/package.c +++ b/libvips/iofuncs/package.c @@ -101,7 +101,7 @@ guess_prefix_vec( im_object *argv ) return( -1 ); } - argv[2] = im_strdup( NULL, prefix ); + argv[2] = vips_strdup( NULL, prefix ); return( 0 ); } @@ -137,7 +137,7 @@ guess_libdir_vec( im_object *argv ) return( -1 ); } - argv[2] = im_strdup( NULL, libdir ); + argv[2] = vips_strdup( NULL, libdir ); return( 0 ); } @@ -293,7 +293,7 @@ history_get_vec( im_object *argv ) const char *str; if( !(str = im_history_get( (IMAGE *) argv[0] )) || - !(*out = im_strdup( NULL, str )) ) + !(*out = vips_strdup( NULL, str )) ) return( -1 ); return( 0 ); @@ -382,7 +382,7 @@ static im_arg_desc version_string_args[] = { static int version_string_vec( im_object *argv ) { - if( !(argv[0] = im_strdup( NULL, vips_version_string() )) ) + if( !(argv[0] = vips_strdup( NULL, vips_version_string() )) ) return( -1 ); return( 0 ); @@ -595,7 +595,7 @@ plugin_free( Plugin *plug ) } VIPS_FREE( plug->name ); plug->pack = NULL; - im_free( plug ); + vips_free( plug ); plugin_list = g_slist_remove( plugin_list, plug ); @@ -626,7 +626,7 @@ im_load_plugin( const char *name ) /* Attach name. */ - if( !(plug->name = im_strdup( NULL, name )) ) { + if( !(plug->name = vips_strdup( NULL, name )) ) { plugin_free( plug ); return( NULL ); } @@ -858,7 +858,7 @@ im_free_vargv( im_function *fn, im_object *vargv ) /* If there is local storage, free it. */ if( fn->argv[i].desc->size != 0 ) - im_free( vargv[i] ); + vips_free( vargv[i] ); /* NULL out pointer. */ @@ -887,7 +887,7 @@ im_allocate_vargv( im_function *fn, im_object *vargv ) int sz = fn->argv[i].desc->size; if( sz != 0 ) - if( !(vargv[i] = im_malloc( NULL, sz )) ) { + if( !(vargv[i] = vips_malloc( NULL, sz )) ) { /* Free anything we did allocate. */ (void) im_free_vargv( fn, vargv ); diff --git a/libvips/iofuncs/region.c b/libvips/iofuncs/region.c index e29ec714..87e3d899 100644 --- a/libvips/iofuncs/region.c +++ b/libvips/iofuncs/region.c @@ -266,8 +266,8 @@ vips__region_stop( VipsRegion *region ) static void vips_region_reset( VipsRegion *region ) { - VIPS_FREEF( im_window_unref, region->window ); - VIPS_FREEF( im_buffer_unref, region->buffer ); + VIPS_FREEF( vips_window_unref, region->window ); + VIPS_FREEF( vips_buffer_unref, region->buffer ); region->invalid = FALSE; } @@ -378,7 +378,7 @@ vips__region_no_ownership( VipsRegion *region ) region->thread = NULL; if( region->buffer ) - im_buffer_undone( region->buffer ); + vips_buffer_undone( region->buffer ); g_mutex_unlock( region->im->sslock ); } @@ -501,7 +501,7 @@ vips_region_buffer( VipsRegion *reg, VipsRect *r ) */ if( reg->invalid ) { vips_region_reset( reg ); - if( !(reg->buffer = im_buffer_new( im, &clipped )) ) + if( !(reg->buffer = vips_buffer_new( im, &clipped )) ) return( -1 ); } else { @@ -509,9 +509,9 @@ vips_region_buffer( VipsRegion *reg, VipsRect *r ) * and new buffer ref in one call to reduce malloc/free * cycling. */ - VIPS_FREEF( im_window_unref, reg->window ); + VIPS_FREEF( vips_window_unref, reg->window ); if( !(reg->buffer = - im_buffer_unref_ref( reg->buffer, im, &clipped )) ) + vips_buffer_unref_ref( reg->buffer, im, &clipped )) ) return( -1 ); } @@ -586,7 +586,7 @@ vips_region_image( VipsRegion *reg, VipsRect *r ) clipped.top + clipped.height ) { vips_region_reset( reg ); - if( !(reg->window = im_window_ref( reg->im, + if( !(reg->window = vips_window_ref( reg->im, clipped.top, clipped.height )) ) return( -1 ); @@ -800,7 +800,7 @@ vips_region_fill( VipsRegion *reg, VipsRect *r, VipsRegionFillFn fn, void *a ) /* Publish our results. */ if( reg->buffer ) - im_buffer_done( reg->buffer ); + vips_buffer_done( reg->buffer ); } return( 0 ); diff --git a/libvips/iofuncs/sinkdisc.c b/libvips/iofuncs/sinkdisc.c index 2b211f83..d6fe3c98 100644 --- a/libvips/iofuncs/sinkdisc.c +++ b/libvips/iofuncs/sinkdisc.c @@ -172,7 +172,7 @@ wbuffer_free( WriteBuffer *wbuffer ) im_semaphore_destroy( &wbuffer->go ); im_semaphore_destroy( &wbuffer->nwrite ); im_semaphore_destroy( &wbuffer->done ); - im_free( wbuffer ); + vips_free( wbuffer ); } static void diff --git a/libvips/iofuncs/sinkscreen.c b/libvips/iofuncs/sinkscreen.c index edd9f05b..3460e8a9 100644 --- a/libvips/iofuncs/sinkscreen.c +++ b/libvips/iofuncs/sinkscreen.c @@ -209,7 +209,7 @@ tile_free( Tile *tile ) VIPS_DEBUG_MSG_AMBER( "tile_free\n" ); VIPS_UNREF( tile->region ); - im_free( tile ); + vips_free( tile ); return( NULL ); } @@ -241,7 +241,7 @@ render_free( Render *render ) VIPS_FREEF( g_slist_free, render->dirty ); VIPS_FREEF( g_hash_table_destroy, render->tiles ); - im_free( render ); + vips_free( render ); #ifdef VIPS_DEBUG_AMBER render_num_renders -= 1; diff --git a/libvips/iofuncs/util.c b/libvips/iofuncs/util.c index 1882856e..9ea78245 100644 --- a/libvips/iofuncs/util.c +++ b/libvips/iofuncs/util.c @@ -168,10 +168,10 @@ im_slist_fold2( GSList *list, void *start, VSListFold2Fn fn, void *a, void *b ) static void im_slist_free_all_cb( void * thing, void * dummy ) { - im_free( thing ); + vips_free( thing ); } -/* Free a g_slist of things which need im_free()ing. +/* Free a g_slist of things which need vips_free()ing. */ void im_slist_free_all( GSList *list ) @@ -276,21 +276,6 @@ im_strrstr( const char *haystack, const char *needle ) return( NULL ); } -/* strdup local to a descriptor. - */ -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 ); -} - /* Test for string b ends string a. */ gboolean @@ -703,12 +688,12 @@ im__file_read( FILE *fp, const char *filename, unsigned int *length_out ) else { /* Allocate memory and fill. */ - if( !(str = im_malloc( NULL, len + 1 )) ) + if( !(str = vips_malloc( NULL, len + 1 )) ) return( NULL ); rewind( fp ); read = fread( str, sizeof( char ), (size_t) len, fp ); if( read != (size_t) len ) { - im_free( str ); + vips_free( str ); vips_error( "im__file_read", _( "error reading from file \"%s\"" ), filename ); @@ -971,7 +956,7 @@ im__gslist_gvalue_get( const GSList *list ) /* +1 for '\0'. */ - if( !(all = im_malloc( NULL, length + 1 )) ) + if( !(all = vips_malloc( NULL, length + 1 )) ) return( NULL ); q = all; diff --git a/libvips/iofuncs/vips.c b/libvips/iofuncs/vips.c index 13e77e40..0cdff684 100644 --- a/libvips/iofuncs/vips.c +++ b/libvips/iofuncs/vips.c @@ -322,10 +322,10 @@ read_chunk( int fd, gint64 offset, size_t length ) if( im__seek( fd, offset ) ) return( NULL ); - if( !(buf = im_malloc( NULL, length + 1 )) ) + if( !(buf = vips_malloc( NULL, length + 1 )) ) return( NULL ); if( read( fd, buf, length ) != (ssize_t) length ) { - im_free( buf ); + vips_free( buf ); vips_error( "VipsImage", "%s", _( "unable to read history" ) ); return( NULL ); } @@ -399,10 +399,10 @@ read_xml( IMAGE *im ) if( !(buf = im__read_extension_block( im, &size )) ) return( NULL ); if( !(doc = xmlParseMemory( buf, size )) ) { - im_free( buf ); + vips_free( buf ); return( NULL ); } - im_free( buf ); + vips_free( buf ); if( !(node = xmlDocGetRootElement( doc )) || !node->nsDef || !im_isprefix( NAMESPACE, (char *) node->nsDef->href ) ) { diff --git a/libvips/iofuncs/window.c b/libvips/iofuncs/window.c index 55ce2a0b..e2db02a8 100644 --- a/libvips/iofuncs/window.c +++ b/libvips/iofuncs/window.c @@ -88,7 +88,7 @@ static int max_mmap_usage = 0; #endif /*DEBUG_TOTAL*/ static int -im_window_unmap( im_window_t *window ) +vips_window_unmap( VipsWindow *window ) { /* unmap the old window */ @@ -112,34 +112,34 @@ im_window_unmap( im_window_t *window ) } static int -im_window_free( im_window_t *window ) +vips_window_free( VipsWindow *window ) { assert( window->ref_count == 0 ); #ifdef DEBUG - printf( "** im_window_free: window top = %d, height = %d (%p)\n", + printf( "** vips_window_free: window top = %d, height = %d (%p)\n", window->top, window->height, window ); #endif /*DEBUG*/ - if( im_window_unmap( window ) ) + if( vips_window_unmap( window ) ) return( -1 ); window->im = NULL; - im_free( window ); + vips_free( window ); return( 0 ); } int -im_window_unref( im_window_t *window ) +vips_window_unref( VipsWindow *window ) { IMAGE *im = window->im; g_mutex_lock( im->sslock ); #ifdef DEBUG - printf( "im_window_unref: window top = %d, height = %d, count = %d\n", + printf( "vips_window_unref: window top = %d, height = %d, count = %d\n", window->top, window->height, window->ref_count ); #endif /*DEBUG*/ @@ -152,11 +152,11 @@ im_window_unref( im_window_t *window ) im->windows = g_slist_remove( im->windows, window ); #ifdef DEBUG - printf( "im_window_unref: %d windows left\n", + printf( "vips_window_unref: %d windows left\n", g_slist_length( im->windows ) ); #endif /*DEBUG*/ - if( im_window_free( window ) ) { + if( vips_window_free( window ) ) { g_mutex_unlock( im->sslock ); return( -1 ); } @@ -178,7 +178,7 @@ trace_mmap_usage( void ) int max = max_mmap_usage / (1024 * 1024); if( total != last_total ) { - printf( "im_window_set: current mmap " + printf( "vips_window_set: current mmap " "usage of ~%dMB (high water mark %dMB)\n", total, max ); last_total = total; @@ -215,7 +215,7 @@ im_getpagesize() /* Map a window into a file. */ static int -im_window_set( im_window_t *window, int top, int height ) +vips_window_set( VipsWindow *window, int top, int height ) { int pagesize = im_getpagesize(); @@ -236,7 +236,7 @@ im_window_set( im_window_t *window, int top, int height ) /* Make sure we have enough file. */ if( end > window->im->file_length ) { - vips_error( "im_window_set", + vips_error( "vips_window_set", _( "unable to read data for \"%s\", %s" ), window->im->filename, _( "file has been truncated" ) ); return( -1 ); @@ -271,12 +271,12 @@ im_window_set( im_window_t *window, int top, int height ) /* Make a new window. */ -static im_window_t * -im_window_new( IMAGE *im, int top, int height ) +static VipsWindow * +vips_window_new( IMAGE *im, int top, int height ) { - im_window_t *window; + VipsWindow *window; - if( !(window = VIPS_NEW( NULL, im_window_t )) ) + if( !(window = VIPS_NEW( NULL, VipsWindow )) ) return( NULL ); window->ref_count = 0; @@ -287,8 +287,8 @@ im_window_new( IMAGE *im, int top, int height ) window->baseaddr = NULL; window->length = 0; - if( im_window_set( window, top, height ) ) { - im_window_free( window ); + if( vips_window_set( window, top, height ) ) { + vips_window_free( window ); return( NULL ); } @@ -296,7 +296,7 @@ im_window_new( IMAGE *im, int top, int height ) window->ref_count += 1; #ifdef DEBUG - printf( "** im_window_new: window top = %d, height = %d (%p)\n", + printf( "** vips_window_new: window top = %d, height = %d (%p)\n", window->top, window->height, window ); #endif /*DEBUG*/ @@ -311,7 +311,7 @@ typedef struct { } request_t; static void * -im_window_fits( im_window_t *window, request_t *req ) +vips_window_fits( VipsWindow *window, request_t *req ) { if( window->top <= req->top && window->top + window->height >= req->top + req->height ) @@ -322,22 +322,22 @@ im_window_fits( im_window_t *window, request_t *req ) /* Find an existing window that fits within top/height and return a ref. */ -static im_window_t * -im_window_find( IMAGE *im, int top, int height ) +static VipsWindow * +vips_window_find( IMAGE *im, int top, int height ) { request_t req; - im_window_t *window; + VipsWindow *window; req.top = top; req.height = height; window = im_slist_map2( im->windows, - (VSListMap2Fn) im_window_fits, &req, NULL ); + (VSListMap2Fn) vips_window_fits, &req, NULL ); if( window ) { window->ref_count += 1; #ifdef DEBUG - printf( "im_window_find: ref window top = %d, height = %d, " + printf( "vips_window_find: ref window top = %d, height = %d, " "count = %d\n", top, height, window->ref_count ); #endif /*DEBUG*/ @@ -348,14 +348,14 @@ im_window_find( IMAGE *im, int top, int height ) /* Return a ref to a window that encloses top/height. */ -im_window_t * -im_window_ref( IMAGE *im, int top, int height ) +VipsWindow * +vips_window_ref( IMAGE *im, int top, int height ) { - im_window_t *window; + VipsWindow *window; g_mutex_lock( im->sslock ); - if( !(window = im_window_find( im, top, height )) ) { + if( !(window = vips_window_find( im, top, height )) ) { /* No existing window ... make a new one. Ask for a larger * window than we strictly need. There's no point making tiny * windows. @@ -370,7 +370,7 @@ im_window_ref( IMAGE *im, int top, int height ) top = VIPS_CLIP( 0, top, im->Ysize - 1 ); height = VIPS_CLIP( 0, height, im->Ysize - top ); - if( !(window = im_window_new( im, top, height )) ) { + if( !(window = vips_window_new( im, top, height )) ) { g_mutex_unlock( im->sslock ); return( NULL ); } @@ -382,9 +382,9 @@ im_window_ref( IMAGE *im, int top, int height ) } void -im_window_print( im_window_t *window ) +vips_window_print( VipsWindow *window ) { - printf( "im_window_t: %p ref_count = %d, ", window, window->ref_count ); + printf( "VipsWindow: %p ref_count = %d, ", window, window->ref_count ); printf( "im = %p, ", window->im ); printf( "top = %d, ", window->top ); printf( "height = %d, ", window->height );