From ab427d906b768682cbb6a39ea5526b8b2336442a Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Thu, 3 Mar 2011 17:54:08 +0000 Subject: [PATCH] iofuncs compiles except for a reset thing we need argh --- TODO | 7 +++ libvips/include/vips/vector.h | 2 +- libvips/iofuncs/buf.c | 8 ++-- libvips/iofuncs/buffer.c | 22 +++++----- libvips/iofuncs/im_init_world.c | 54 +++++++++++------------ libvips/iofuncs/semaphore.c | 4 +- libvips/iofuncs/sinkdisc.c | 2 +- libvips/iofuncs/threadpool.c | 57 ++++++++++++------------ libvips/iofuncs/util.c | 78 ++++++++------------------------- libvips/iofuncs/vector.c | 13 +++--- libvips/iofuncs/window.c | 17 +++---- 11 files changed, 118 insertions(+), 146 deletions(-) diff --git a/TODO b/TODO index 84e03c8b..9ee7e821 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,10 @@ +- need some way to reset descriptors for rewind, see: + + check.c: In function ‘im_incheck’: + check.c:235: warning: implicit declaration of function ‘im_openin’ + + is this the only place? does im_pincheck() do a rewind too? + - why not renname VipsBandFormat as VipsFormat? cf. VipsCoding, VipsInterpretation etc. diff --git a/libvips/include/vips/vector.h b/libvips/include/vips/vector.h index 6528938b..9aeb6593 100644 --- a/libvips/include/vips/vector.h +++ b/libvips/include/vips/vector.h @@ -125,7 +125,7 @@ void vips_vector_print( VipsVector *vector ); void vips_executor_set_program( VipsExecutor *executor, VipsVector *vector, int n ); void vips_executor_set_scanline( VipsExecutor *executor, - REGION *ir, int x, int y ); + VipsRegion *ir, int x, int y ); void vips_executor_set_destination( VipsExecutor *executor, void *value ); void vips_executor_set_array( VipsExecutor *executor, int var, void *value ); diff --git a/libvips/iofuncs/buf.c b/libvips/iofuncs/buf.c index 5ea96d25..86650f4a 100644 --- a/libvips/iofuncs/buf.c +++ b/libvips/iofuncs/buf.c @@ -135,7 +135,7 @@ void vips_buf_destroy( VipsBuf *buf ) { if( buf->dynamic ) { - IM_FREE( buf->base ); + VIPS_FREE( buf->base ); } vips_buf_init( buf ); @@ -211,7 +211,7 @@ vips_buf_set_dynamic( VipsBuf *buf, int mx ) else { vips_buf_destroy( buf ); - if( !(buf->base = IM_ARRAY( NULL, mx, char )) ) + if( !(buf->base = VIPS_ARRAY( NULL, mx, char )) ) /* No error return, so just block writes. */ buf->full = TRUE; @@ -274,7 +274,7 @@ vips_buf_appendns( VipsBuf *buf, const char *str, int sz ) */ len = strlen( str ); if( sz >= 0 ) - n = IM_MIN( sz, len ); + n = VIPS_MIN( sz, len ); else n = len; @@ -284,7 +284,7 @@ vips_buf_appendns( VipsBuf *buf, const char *str, int sz ) /* Amount we actually copy. */ - cpy = IM_MIN( n, avail ); + cpy = VIPS_MIN( n, avail ); strncpy( buf->base + buf->i, str, cpy ); buf->i += cpy; diff --git a/libvips/iofuncs/buffer.c b/libvips/iofuncs/buffer.c index bf450986..8c28ecb0 100644 --- a/libvips/iofuncs/buffer.c +++ b/libvips/iofuncs/buffer.c @@ -94,8 +94,8 @@ buffer_cache_free( im_buffer_cache_t *cache ) printf( "\t(%d cachees left)\n", buffer_cache_n ); #endif /*DEBUG_CREATE*/ - IM_FREEF( g_hash_table_destroy, cache->hash ); - IM_FREE( cache ); + VIPS_FREEF( g_hash_table_destroy, cache->hash ); + VIPS_FREE( cache ); } #endif /*HAVE_THREADS*/ @@ -122,7 +122,7 @@ buffer_cache_list_new( im_buffer_cache_t *cache, IMAGE *im ) { im_buffer_cache_list_t *cache_list; - if( !(cache_list = IM_NEW( NULL, im_buffer_cache_list_t )) ) + if( !(cache_list = VIPS_NEW( NULL, im_buffer_cache_list_t )) ) return( NULL ); cache_list->buffers = NULL; cache_list->thread = g_thread_self(); @@ -143,7 +143,7 @@ buffer_cache_new( void ) { im_buffer_cache_t *cache; - if( !(cache = IM_NEW( NULL, im_buffer_cache_t )) ) + if( !(cache = VIPS_NEW( NULL, im_buffer_cache_t )) ) return( NULL ); cache->hash = g_hash_table_new_full( g_direct_hash, g_direct_equal, @@ -275,7 +275,7 @@ im_buffer_unref( im_buffer_t *buffer ) im_buffer_undone( buffer ); buffer->im = NULL; - IM_FREE( buffer->buf ); + VIPS_FREE( buffer->buf ); buffer->bsize = 0; im_free( buffer ); @@ -297,7 +297,7 @@ im_buffer_new( IMAGE *im, Rect *area ) { im_buffer_t *buffer; - if( !(buffer = IM_NEW( NULL, im_buffer_t )) ) + if( !(buffer = VIPS_NEW( NULL, im_buffer_t )) ) return( NULL ); buffer->ref_count = 1; @@ -305,7 +305,7 @@ im_buffer_new( IMAGE *im, Rect *area ) buffer->area = *area; buffer->done = FALSE; buffer->cache = NULL; - buffer->bsize = (size_t) IM_IMAGE_SIZEOF_PEL( im ) * + 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 ); @@ -342,11 +342,11 @@ buffer_move( im_buffer_t *buffer, Rect *area ) im_buffer_undone( buffer ); g_assert( !buffer->done ); - new_bsize = (size_t) IM_IMAGE_SIZEOF_PEL( im ) * + new_bsize = (size_t) VIPS_IMAGE_SIZEOF_PEL( im ) * area->width * area->height; if( buffer->bsize < new_bsize ) { buffer->bsize = new_bsize; - IM_FREE( buffer->buf ); + VIPS_FREE( buffer->buf ); if( !(buffer->buf = im_malloc( NULL, buffer->bsize )) ) return( -1 ); } @@ -438,7 +438,7 @@ im_buffer_unref_ref( im_buffer_t *old_buffer, IMAGE *im, Rect *area ) /* Does the new area already have a buffer? */ if( (buffer = buffer_find( im, area )) ) { - IM_FREEF( im_buffer_unref, old_buffer ); + VIPS_FREEF( im_buffer_unref, old_buffer ); return( buffer ); } @@ -455,7 +455,7 @@ im_buffer_unref_ref( im_buffer_t *old_buffer, IMAGE *im, Rect *area ) /* Fallback ... unref the old one, make a new one. */ - IM_FREEF( im_buffer_unref, old_buffer ); + VIPS_FREEF( im_buffer_unref, old_buffer ); if( !(buffer = im_buffer_new( im, area )) ) return( NULL ); diff --git a/libvips/iofuncs/im_init_world.c b/libvips/iofuncs/im_init_world.c index cb883d16..a97e00a9 100644 --- a/libvips/iofuncs/im_init_world.c +++ b/libvips/iofuncs/im_init_world.c @@ -72,38 +72,38 @@ /* Use in various small places where we need a mutex and it's not worth * making a private one. */ -GMutex *im__global_lock = NULL; +GMutex *vips__global_lock = NULL; /* Keep a copy of the argv0 here. */ -static char *im__argv0 = NULL; +static char *vips__argv0 = NULL; /** * im_get_argv0: * - * See also: im_init_world(). + * See also: vips_init_world(). * * Returns: a pointer to an internal copy of the argv0 string passed to - * im_init_world(). Do not free this value + * vips_init_world(). Do not free this value */ const char * -im_get_argv0( void ) +vips_get_argv0( void ) { - return( im__argv0 ); + return( vips__argv0 ); } /** - * im_init_world: + * vips_init_world: * @argv0: name of application * - * im_init_world() starts up the world of VIPS. You should call this on + * vips_init_world() starts up the world of VIPS. You should call this on * program startup before using any other VIPS operations. If you do not call - * im_init_world(), VIPS will call it for you when you use your first VIPS + * vips_init_world(), VIPS will call it for you when you use your first VIPS * operation, but * it may not be able to get hold of @argv0 and VIPS may therefore be unable * to find its data files. It is much better to call this function yourself. * - * im_init_world() does approximately the following: + * vips_init_world() does approximately the following: * * * @@ -127,7 +127,7 @@ im_get_argv0( void ) * |[ * int main( int argc, char **argv ) * { - * if( im_init_world( argv[0] ) ) + * if( vips_init_world( argv[0] ) ) * error_exit( "unable to start VIPS" ); * * return( 0 ); @@ -140,7 +140,7 @@ im_get_argv0( void ) * Returns: 0 on success, -1 otherwise */ int -im_init_world( const char *argv0 ) +vips_init_world( const char *argv0 ) { static gboolean started = FALSE; static gboolean done = FALSE; @@ -164,7 +164,7 @@ im_init_world( const char *argv0 ) return( 0 ); started = TRUE; - IM_SETSTR( im__argv0, argv0 ); + VIPS_SETSTR( vips__argv0, argv0 ); /* Need gobject etc. */ @@ -175,8 +175,8 @@ im_init_world( const char *argv0 ) g_thread_init( NULL ); #endif /*G_THREADS_ENABLED*/ - if( !im__global_lock ) - im__global_lock = g_mutex_new(); + if( !vips__global_lock ) + vips__global_lock = g_mutex_new(); prgname = g_path_get_basename( argv0 ); g_set_prgname( prgname ); @@ -184,8 +184,8 @@ im_init_world( const char *argv0 ) /* Try to discover our prefix. */ - if( !(prefix = im_guess_prefix( argv0, "VIPSHOME" )) || - !(libdir = im_guess_libdir( argv0, "VIPSHOME" )) ) + if( !(prefix = vips_guess_prefix( argv0, "VIPSHOME" )) || + !(libdir = vips_guess_libdir( argv0, "VIPSHOME" )) ) return( -1 ); /* Get i18n .mo files from $VIPSHOME/share/locale/. @@ -208,16 +208,16 @@ im_init_world( const char *argv0 ) */ if( im_load_plugins( "%s/vips-%d.%d", libdir, IM_MAJOR_VERSION, IM_MINOR_VERSION ) ) { - im_warn( "im_init_world", "%s", im_error_buffer() ); - im_error_clear(); + vips_warn( "vips_init_world", "%s", vips_error_buffer() ); + vips_error_clear(); } /* Also load from libdir. This is old and slightly broken behaviour * :-( kept for back compat convenience. */ if( im_load_plugins( "%s", libdir ) ) { - im_warn( "im_init_world", "%s", im_error_buffer() ); - im_error_clear(); + vips_warn( "vips_init_world", "%s", vips_error_buffer() ); + vips_error_clear(); } /* Start up the buffer cache. @@ -237,11 +237,11 @@ const char * im__gettext( const char *msgid ) { /* Pass in a nonsense name for argv0 ... this init path is only here - * for old programs which are missing an im_init_world() call. We need + * for old programs which are missing an vips_init_world() call. We need * i18n set up before we can translate. */ - if( im_init_world( "giant_banana" ) ) - im_error_clear(); + if( vips_init_world( "giant_banana" ) ) + vips_error_clear(); return( dgettext( GETTEXT_PACKAGE, msgid ) ); } @@ -249,8 +249,8 @@ im__gettext( const char *msgid ) const char * im__ngettext( const char *msgid, const char *plural, unsigned long int n ) { - if( im_init_world( "giant_banana" ) ) - im_error_clear(); + if( vips_init_world( "giant_banana" ) ) + vips_error_clear(); return( dngettext( GETTEXT_PACKAGE, msgid, plural, n ) ); } @@ -287,7 +287,7 @@ static GOptionEntry option_entries[] = { * parse argc/argv. * * See also: im_version(), im_guess_prefix(), - * im_guess_libdir(), im_init_world(). + * im_guess_libdir(), vips_init_world(). * * Returns: a GOptionGroup for VIPS, see GOption */ diff --git a/libvips/iofuncs/semaphore.c b/libvips/iofuncs/semaphore.c index 69219d6e..74ddf09b 100644 --- a/libvips/iofuncs/semaphore.c +++ b/libvips/iofuncs/semaphore.c @@ -70,8 +70,8 @@ void im_semaphore_destroy( im_semaphore_t *s ) { #ifdef HAVE_THREADS - IM_FREEF( g_mutex_free, s->mutex ); - IM_FREEF( g_cond_free, s->cond ); + VIPS_FREEF( g_mutex_free, s->mutex ); + VIPS_FREEF( g_cond_free, s->cond ); #endif /*HAVE_THREADS*/ } diff --git a/libvips/iofuncs/sinkdisc.c b/libvips/iofuncs/sinkdisc.c index 5a880548..5f03bd64 100644 --- a/libvips/iofuncs/sinkdisc.c +++ b/libvips/iofuncs/sinkdisc.c @@ -416,7 +416,7 @@ wbuffer_work_fn( VipsThreadState *state, void *a ) VIPS_DEBUG_MSG( "wbuffer_work_fn:\n" ); - if( im_prepare_to( state->reg, wstate->buf->region, + if( vips_region_prepare_to( state->reg, wstate->buf->region, &state->pos, state->pos.left, state->pos.top ) ) return( -1 ); diff --git a/libvips/iofuncs/threadpool.c b/libvips/iofuncs/threadpool.c index 0f4c7c71..e4ad5d75 100644 --- a/libvips/iofuncs/threadpool.c +++ b/libvips/iofuncs/threadpool.c @@ -88,7 +88,7 @@ /* Maximum number of concurrent threads we allow. No reason for the limit, * it's just there to stop mad values for IM_CONCURRENCY killing the system. */ -#define IM_MAX_THREADS (1024) +#define MAX_THREADS (1024) /* Name of environment variable we get concurrency level from. */ @@ -214,10 +214,10 @@ im_concurrency_get( void ) else nthr = get_num_processors(); - if( nthr < 1 || nthr > IM_MAX_THREADS ) { - nthr = IM_CLIP( 1, nthr, IM_MAX_THREADS ); + if( nthr < 1 || nthr > MAX_THREADS ) { + nthr = VIPS_CLIP( 1, nthr, MAX_THREADS ); - im_warn( "im_concurrency_get", + vips_warn( "im_concurrency_get", _( "threads clipped to %d" ), nthr ); } @@ -255,7 +255,7 @@ vips_thread_state_dispose( GObject *gobject ) VIPS_DEBUG_MSG( "vips_thread_state_dispose:\n" ); - IM_FREEF( im_region_free, state->reg ); + VIPS_FREEF( g_object_unref, state->reg ); G_OBJECT_CLASS( vips_thread_state_parent_class )->dispose( gobject ); } @@ -265,7 +265,7 @@ vips_thread_state_build( VipsObject *object ) { VipsThreadState *state = (VipsThreadState *) object; - if( !(state->reg = im_region_create( state->im )) ) + if( !(state->reg = vips_region_new( state->im )) ) return( -1 ); return( VIPS_OBJECT_CLASS( @@ -385,7 +385,7 @@ typedef struct _VipsThreadpool { #ifdef TIME_THREAD /* Size of time buffers. */ -#define IM_TBUF_SIZE (20000) +#define TBUF_SIZE (20000) static GTimer *thread_timer = NULL; #endif /*TIME_THREAD*/ @@ -430,7 +430,7 @@ vips_thread_free( VipsThread *thr ) thr->thread = NULL; } - IM_FREEF( g_object_unref, thr->state ); + VIPS_FREEF( g_object_unref, thr->state ); thr->pool = NULL; #ifdef TIME_THREAD @@ -468,7 +468,7 @@ vips_thread_work( VipsThread *thr ) #ifdef TIME_THREAD /* Note start time. */ - if( thr->btime && thr->tpos < IM_TBUF_SIZE ) + if( thr->btime && thr->tpos < TBUF_SIZE ) thr->btime[thr->tpos] = g_timer_elapsed( thread_timer, NULL ); #endif /*TIME_THREAD*/ @@ -479,7 +479,7 @@ vips_thread_work( VipsThread *thr ) #ifdef TIME_THREAD /* Note stop time. */ - if( thr->etime && thr->tpos < IM_TBUF_SIZE ) { + if( thr->etime && thr->tpos < TBUF_SIZE ) { thr->etime[thr->tpos] = g_timer_elapsed( thread_timer, NULL ); thr->tpos += 1; @@ -570,7 +570,7 @@ vips_thread_new( VipsThreadpool *pool ) { VipsThread *thr; - if( !(thr = IM_NEW( pool->im, VipsThread )) ) + if( !(thr = VIPS_NEW( pool->im, VipsThread )) ) return( NULL ); thr->pool = pool; thr->state = NULL; @@ -589,8 +589,8 @@ vips_thread_new( VipsThreadpool *pool ) */ #ifdef TIME_THREAD - thr->btime = IM_ARRAY( pool->im, IM_TBUF_SIZE, double ); - thr->etime = IM_ARRAY( pool->im, IM_TBUF_SIZE, double ); + thr->btime = VIPS_ARRAY( pool->im, TBUF_SIZE, double ); + thr->etime = VIPS_ARRAY( pool->im, TBUF_SIZE, double ); if( !thr->btime || !thr->etime ) { thread_free( thr ); return( NULL ); @@ -605,7 +605,7 @@ vips_thread_new( VipsThreadpool *pool ) if( !(thr->thread = g_thread_create_full( vips_thread_main_loop, thr, IM__DEFAULT_STACK_SIZE, TRUE, FALSE, G_THREAD_PRIORITY_NORMAL, NULL )) ) { - im_error( "vips_thread_new", + vips_error( "vips_thread_new", "%s", _( "unable to create thread" ) ); vips_thread_free( thr ); return( NULL ); @@ -643,13 +643,19 @@ vips_threadpool_free( VipsThreadpool *pool ) pool->im->filename, pool ); vips_threadpool_kill_threads( pool ); - IM_FREEF( g_mutex_free, pool->allocate_lock ); + VIPS_FREEF( g_mutex_free, pool->allocate_lock ); im_semaphore_destroy( &pool->finish ); im_semaphore_destroy( &pool->tick ); return( 0 ); } +static void +vips_threadpool_new_cb( VipsImage *im, VipsThreadpool *pool ) +{ + vips_threadpool_free( pool ); +} + static VipsThreadpool * vips_threadpool_new( VipsImage *im ) { @@ -657,7 +663,7 @@ vips_threadpool_new( VipsImage *im ) /* Allocate and init new thread block. */ - if( !(pool = IM_NEW( im, VipsThreadpool )) ) + if( !(pool = VIPS_NEW( im, VipsThreadpool )) ) return( NULL ); pool->im = im; pool->allocate = NULL; @@ -672,11 +678,8 @@ vips_threadpool_new( VipsImage *im ) /* Attach tidy-up callback. */ - if( im_add_close_callback( im, - (im_callback_fn) vips_threadpool_free, pool, NULL ) ) { - (void) vips_threadpool_free( pool ); - return( NULL ); - } + g_signal_connect( im, "close", + G_CALLBACK( vips_threadpool_new_cb ), pool ); VIPS_DEBUG_MSG( "vips_threadpool_new: \"%s\" (%p), with %d threads\n", im->filename, pool, pool->nthr ); @@ -695,7 +698,7 @@ vips_threadpool_create_threads( VipsThreadpool *pool ) /* Make thread array. */ - if( !(pool->thr = IM_ARRAY( pool->im, pool->nthr, VipsThread * )) ) + if( !(pool->thr = VIPS_ARRAY( pool->im, pool->nthr, VipsThread * )) ) return( -1 ); for( i = 0; i < pool->nthr; i++ ) pool->thr[i] = NULL; @@ -902,7 +905,7 @@ vips_get_tile_size( VipsImage *im, /* Pick a render geometry. */ switch( im->dhint ) { - case IM_SMALLTILE: + case VIPS_DEMAND_STYLE_SMALLTILE: *tile_width = im__tile_width; *tile_height = im__tile_height; @@ -910,17 +913,17 @@ vips_get_tile_size( VipsImage *im, * nthr busy. Then double it. */ *nlines = *tile_height * - (1 + nthr / IM_MAX( 1, im->Xsize / *tile_width )) * 2; + (1 + nthr / VIPS_MAX( 1, im->Xsize / *tile_width )) * 2; break; - case IM_ANY: - case IM_FATSTRIP: + case VIPS_DEMAND_STYLE_ANY: + case VIPS_DEMAND_STYLE_FATSTRIP: *tile_width = im->Xsize; *tile_height = im__fatstrip_height; *nlines = *tile_height * nthr * 2; break; - case IM_THINSTRIP: + case VIPS_DEMAND_STYLE_THINSTRIP: *tile_width = im->Xsize; *tile_height = im__thinstrip_height; *nlines = *tile_height * nthr * 2; diff --git a/libvips/iofuncs/util.c b/libvips/iofuncs/util.c index 9a7f7682..8e120cef 100644 --- a/libvips/iofuncs/util.c +++ b/libvips/iofuncs/util.c @@ -299,7 +299,7 @@ vips_class_map_concrete_all( GType type, VipsClassMap fn, void *a ) * classes. */ if( !(class = g_type_class_ref( type )) ) { - im_error( "vips_class_map_concrete_all", + vips_error( "vips_class_map_concrete_all", "%s", _( "unable to build class" ) ); return( NULL ); } @@ -337,14 +337,14 @@ vips_class_find( const char *basename, const char *nickname ) GType base; if( !(base = g_type_from_name( basename )) ) { - im_error( "vips_class_find", + vips_error( "vips_class_find", _( "base class \"%s\" not found" ), basename ); return( NULL ); } if( !(class = vips_class_map_concrete_all( base, (VipsClassMap) test_name, (void *) nickname )) ) { - im_error( "vips_class_find", + vips_error( "vips_class_find", _( "class \"%s\" not found" ), nickname ); return( NULL ); } @@ -731,46 +731,6 @@ im_getsuboption( const char *buf ) return( p ); } -/* Make something local to an image descriptor ... pass in a constructor - * and a destructor, plus three args. - */ -void * -im_local( IMAGE *im, - im_construct_fn cons, im_callback_fn dest, void *a, void *b, void *c ) -{ - void *obj; - - if( !im ) { - im_error( "im_local", "%s", _( "NULL image descriptor" ) ); - return( NULL ); - } - - if( !(obj = cons( a, b, c )) ) - return( NULL ); - if( im_add_close_callback( im, (im_callback_fn) dest, obj, a ) ) { - dest( obj, a ); - return( NULL ); - } - - return( obj ); -} - -/* Make an array of things local to a descriptor ... eg. make 6 local temp - * images. - */ -int -im_local_array( IMAGE *im, void **out, int n, - im_construct_fn cons, im_callback_fn dest, void *a, void *b, void *c ) -{ - int i; - - for( i = 0; i < n; i++ ) - if( !(out[i] = im_local( im, cons, dest, a, b, c )) ) - return( -1 ); - - return( 0 ); -} - /* Get file length ... 64-bitally. -1 for error. */ gint64 @@ -785,7 +745,7 @@ im_file_length( int fd ) if( fstat( fd, &st ) == -1 ) { #endif /*OS_WIN32*/ - im_error_system( errno, "im_file_length", + vips_error_system( errno, "im_file_length", "%s", _( "unable to get file stats" ) ); return( -1 ); } @@ -802,7 +762,7 @@ im__write( int fd, const void *buf, size_t count ) size_t nwritten = write( fd, buf, count ); if( nwritten == (size_t) -1 ) { - im_error_system( errno, "im__write", + vips_error_system( errno, "im__write", "%s", _( "write failed" ) ); return( -1 ); } @@ -830,7 +790,7 @@ im__file_read( FILE *fp, const char *filename, unsigned int *length_out ) if( len > 20 * 1024 * 1024 ) { /* Seems crazy! */ - im_error( "im__file_read", _( "\"%s\" too long" ), filename ); + vips_error( "im__file_read", _( "\"%s\" too long" ), filename ); return( NULL ); } @@ -846,7 +806,7 @@ im__file_read( FILE *fp, const char *filename, unsigned int *length_out ) do { size += 1024; if( !(str = realloc( str, size )) ) { - im_error( "im__file_read", + vips_error( "im__file_read", "%s", _( "out of memory" ) ); return( NULL ); } @@ -872,7 +832,7 @@ im__file_read( FILE *fp, const char *filename, unsigned int *length_out ) read = fread( str, sizeof( char ), (size_t) len, fp ); if( read != (size_t) len ) { im_free( str ); - im_error( "im__file_read", + vips_error( "im__file_read", _( "error reading from file \"%s\"" ), filename ); return( NULL ); @@ -939,7 +899,7 @@ im__file_open_read( const char *filename, const char *fallback_dir, return( fp ); } - im_error( "im__file_open_read", + vips_error( "im__file_open_read", _( "unable to open file \"%s\" for reading" ), filename ); return( NULL ); @@ -961,7 +921,7 @@ im__file_open_write( const char *filename, gboolean text_mode ) #endif /*BINARY_OPEN*/ if( !(fp = fopen( filename, mode )) ) { - im_error( "im__file_open_write", + vips_error( "im__file_open_write", _( "unable to open file \"%s\" for writing" ), filename ); return( NULL ); @@ -1164,14 +1124,14 @@ im__seek( int fd, gint64 pos ) p.QuadPart = pos; if( !SetFilePointerEx( hFile, p, NULL, FILE_BEGIN ) ) { - im_error_system( GetLastError(), "im__seek", + vips_error_system( GetLastError(), "im__seek", "%s", _( "unable to seek" ) ); return( -1 ); } } #else /*!OS_WIN32*/ if( lseek( fd, pos, SEEK_SET ) == (off_t) -1 ) { - im_error( "im__seek", "%s", _( "unable to seek" ) ); + vips_error( "im__seek", "%s", _( "unable to seek" ) ); return( -1 ); } #endif /*OS_WIN32*/ @@ -1198,14 +1158,14 @@ im__ftruncate( int fd, gint64 pos ) if( im__seek( fd, pos ) ) return( -1 ); if( !SetEndOfFile( hFile ) ) { - im_error_system( GetLastError(), "im__ftruncate", + vips_error_system( GetLastError(), "im__ftruncate", "%s", _( "unable to truncate" ) ); return( -1 ); } } #else /*!OS_WIN32*/ if( ftruncate( fd, pos ) ) { - im_error_system( errno, "im__ftruncate", + vips_error_system( errno, "im__ftruncate", "%s", _( "unable to truncate" ) ); return( -1 ); } @@ -1225,7 +1185,7 @@ im__file_write( void *data, size_t size, size_t nmemb, FILE *stream ) return( 0 ); if( (n = fwrite( data, size, nmemb, stream )) != nmemb ) { - im_error( "im__file_write", + vips_error( "im__file_write", _( "writing error (%zd out of %zd blocks written) " "... disc full?" ), n, nmemb ); return( -1 ); @@ -1377,7 +1337,7 @@ vips__token_must( const char *p, VipsToken *token, char *string, int size ) { if( !(p = vips__token_get( p, token, string, size )) ) { - im_error( "get_token", "%s", _( "unexpected end of string" ) ); + vips_error( "get_token", "%s", _( "unexpected end of string" ) ); return( NULL ); } @@ -1412,7 +1372,7 @@ vips__token_need( const char *p, VipsToken need_token, if( !(p = vips__token_must( p, &token, string, size )) ) return( NULL ); if( token != need_token ) { - im_error( "get_token", _( "expected %s, saw %s" ), + vips_error( "get_token", _( "expected %s, saw %s" ), vips__token_string( need_token ), vips__token_string( token ) ); return( NULL ); @@ -1464,7 +1424,7 @@ im_popenf( const char *fmt, const char *mode, ... ) #endif /*DEBUG*/ if( !(fp = popen( buf, mode )) ) { - im_error( "popenf", "%s", strerror( errno ) ); + vips_error( "popenf", "%s", strerror( errno ) ); return( NULL ); } @@ -1563,7 +1523,7 @@ im__temp_name( const char *format ) name = g_build_filename( im__temp_dir(), file2, NULL ); if( (fd = g_mkstemp( name )) == -1 ) { - im_error( "tempfile", + vips_error( "tempfile", _( "unable to make temporary file %s" ), name ); g_free( name ); return( NULL ); diff --git a/libvips/iofuncs/vector.c b/libvips/iofuncs/vector.c index 0597ba8d..563ced57 100644 --- a/libvips/iofuncs/vector.c +++ b/libvips/iofuncs/vector.c @@ -105,9 +105,9 @@ void vips_vector_free( VipsVector *vector ) { #ifdef HAVE_ORC - IM_FREEF( orc_program_free, vector->program ); + VIPS_FREEF( orc_program_free, vector->program ); #endif /*HAVE_ORC*/ - IM_FREE( vector ); + VIPS_FREE( vector ); } VipsVector * @@ -116,7 +116,7 @@ vips_vector_new( const char *name, int dsize ) VipsVector *vector; int i; - if( !(vector = IM_NEW( NULL, VipsVector )) ) + if( !(vector = VIPS_NEW( NULL, VipsVector )) ) return( NULL ); vector->name = name; vector->n_temp = 0; @@ -348,11 +348,12 @@ vips_executor_set_array( VipsExecutor *executor, int var, void *value ) } void -vips_executor_set_scanline( VipsExecutor *executor, REGION *ir, int x, int y ) +vips_executor_set_scanline( VipsExecutor *executor, + VipsRegion *ir, int x, int y ) { VipsVector *vector = executor->vector; - PEL *base = (PEL *) IM_REGION_ADDR( ir, x, y ); - int lsk = IM_REGION_LSKIP( ir ); + PEL *base = (PEL *) VIPS_REGION_ADDR( ir, x, y ); + int lsk = VIPS_REGION_LSKIP( ir ); int i; diff --git a/libvips/iofuncs/window.c b/libvips/iofuncs/window.c index 5c612fb3..e226c83e 100644 --- a/libvips/iofuncs/window.c +++ b/libvips/iofuncs/window.c @@ -226,8 +226,8 @@ im_window_set( im_window_t *window, int top, int height ) /* Calculate start and length for our window. */ start = window->im->sizeof_header + - (gint64) IM_IMAGE_SIZEOF_LINE( window->im ) * top; - length = (size_t) IM_IMAGE_SIZEOF_LINE( window->im ) * height; + VIPS_IMAGE_SIZEOF_LINE( window->im ) * top; + length = VIPS_IMAGE_SIZEOF_LINE( window->im ) * height; pagestart = start - start % pagesize; end = start + length; @@ -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 ) { - im_error( "im_window_set", + vips_error( "im_window_set", _( "unable to read data for \"%s\", %s" ), window->im->filename, _( "file has been truncated" ) ); return( -1 ); @@ -275,7 +275,7 @@ im_window_new( IMAGE *im, int top, int height ) { im_window_t *window; - if( !(window = IM_NEW( NULL, im_window_t )) ) + if( !(window = VIPS_NEW( NULL, im_window_t )) ) return( NULL ); window->ref_count = 0; @@ -359,14 +359,15 @@ im_window_ref( IMAGE *im, int top, int height ) * window than we strictly need. There's no point making tiny * windows. */ - int margin = IM_MIN( im__window_margin_pixels, - im__window_margin_bytes / IM_IMAGE_SIZEOF_LINE( im ) ); + int margin = VIPS_MIN( im__window_margin_pixels, + im__window_margin_bytes / + VIPS_IMAGE_SIZEOF_LINE( im ) ); top -= margin; height += margin * 2; - top = IM_CLIP( 0, top, im->Ysize - 1 ); - height = IM_CLIP( 0, height, im->Ysize - top ); + top = VIPS_CLIP( 0, top, im->Ysize - 1 ); + height = VIPS_CLIP( 0, height, im->Ysize - top ); if( !(window = im_window_new( im, top, height )) ) { g_mutex_unlock( im->sslock );