make vips_object_get_args() return an int
since malloc can fail
This commit is contained in:
parent
30cb95e6e7
commit
fec2f5f869
@ -302,7 +302,7 @@ typedef void *(*VipsArgumentMapFn)( VipsObject *object, GParamSpec *pspec,
|
|||||||
VipsArgumentInstance *argument_instance, void *a, void *b );
|
VipsArgumentInstance *argument_instance, void *a, void *b );
|
||||||
void *vips_argument_map( VipsObject *object,
|
void *vips_argument_map( VipsObject *object,
|
||||||
VipsArgumentMapFn fn, void *a, void *b );
|
VipsArgumentMapFn fn, void *a, void *b );
|
||||||
void vips_object_get_args( VipsObject *object,
|
int vips_object_get_args( VipsObject *object,
|
||||||
const char ***names, int **flags, int *n_args );
|
const char ***names, int **flags, int *n_args );
|
||||||
typedef void *(*VipsArgumentClassMapFn)( VipsObjectClass *object_class,
|
typedef void *(*VipsArgumentClassMapFn)( VipsObjectClass *object_class,
|
||||||
GParamSpec *pspec,
|
GParamSpec *pspec,
|
||||||
|
@ -2236,29 +2236,34 @@ vips_object_find_args( VipsObject *object,
|
|||||||
/**
|
/**
|
||||||
* vips_object_get_args: (skip)
|
* vips_object_get_args: (skip)
|
||||||
* @object: object whose args should be retrieved
|
* @object: object whose args should be retrieved
|
||||||
* @names: (out)(array length=n_args): output array of GParamSpec names
|
* @names: (transfer none) (array length=n_args) (allow-none): output array of %GParamSpec names
|
||||||
* @flags: (out)(array length=n_args): output array of VipsArgumentFlags
|
* @flags: (transfer none) (array length=n_args) (allow-none): output array of #VipsArgumentFlags
|
||||||
* @n_args: length of output arrays
|
* @n_args: (allow-none): length of output arrays
|
||||||
*
|
*
|
||||||
* Get all GParamSpec names and VipsArgumentFlags for an object.
|
* Get all %GParamSpec names and #VipsArgumentFlags for an object.
|
||||||
*
|
*
|
||||||
* This is handy for language bindings. From C, it's usually more convenient to
|
* This is handy for language bindings. From C, it's usually more convenient to
|
||||||
* use vips_argument_map().
|
* use vips_argument_map().
|
||||||
|
*
|
||||||
|
* Returns: 0 on success, -1 on error
|
||||||
*/
|
*/
|
||||||
void
|
int
|
||||||
vips_object_get_args( VipsObject *object,
|
vips_object_get_args( VipsObject *object,
|
||||||
const char ***names, int **flags, int *n_args )
|
const char ***names, int **flags, int *n_args )
|
||||||
{
|
{
|
||||||
VipsObjectClass *object_class = VIPS_OBJECT_GET_CLASS( object );
|
VipsObjectClass *object_class = VIPS_OBJECT_GET_CLASS( object );
|
||||||
|
|
||||||
int n = g_slist_length( object_class->argument_table_traverse );
|
int n = g_slist_length( object_class->argument_table_traverse );
|
||||||
|
|
||||||
VipsNameFlagsPair pair;
|
VipsNameFlagsPair pair;
|
||||||
|
int i;
|
||||||
|
|
||||||
pair.names = VIPS_ARRAY( object, n, const char * );
|
pair.names = VIPS_ARRAY( object, n, const char * );
|
||||||
pair.flags = VIPS_ARRAY( object, n, int );
|
pair.flags = VIPS_ARRAY( object, n, int );
|
||||||
|
if( !pair.names ||
|
||||||
|
!pair.flags )
|
||||||
|
return( -1 );
|
||||||
|
|
||||||
int i = 0;
|
i = 0;
|
||||||
|
|
||||||
(void) vips_argument_map( object,
|
(void) vips_argument_map( object,
|
||||||
vips_object_find_args, &pair, &i );
|
vips_object_find_args, &pair, &i );
|
||||||
|
|
||||||
@ -2268,6 +2273,8 @@ vips_object_get_args( VipsObject *object,
|
|||||||
*flags = pair.flags;
|
*flags = pair.flags;
|
||||||
if( n_args )
|
if( n_args )
|
||||||
*n_args = n;
|
*n_args = n;
|
||||||
|
|
||||||
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user