From f7ea70e422fafdc886d5829d1bb5f9f3e75d726f Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 10 Jul 2020 11:57:47 +0200 Subject: Move image structure creation up to image_read() --- libcrystfel/src/image-hdf5.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'libcrystfel/src/image-hdf5.c') diff --git a/libcrystfel/src/image-hdf5.c b/libcrystfel/src/image-hdf5.c index 5461c8a5..5b7a9728 100644 --- a/libcrystfel/src/image-hdf5.c +++ b/libcrystfel/src/image-hdf5.c @@ -525,23 +525,18 @@ static int load_hdf5_hyperslab(struct panel_template *p, } -struct image *image_hdf5_read(DataTemplate *dtempl, - const char *filename, const char *event) +int image_hdf5_read(struct image *image, + DataTemplate *dtempl, + const char *filename, + const char *event) { - struct image *image; int i; - image = image_new(); - if ( image == NULL ) { - ERROR("Couldn't allocate image structure.\n"); - return NULL; - } - image->dp = malloc(dtempl->n_panels*sizeof(float *)); if ( image->dp == NULL ) { ERROR("Failed to allocate data array.\n"); image_free(image); - return NULL; + return 1; } if ( event == NULL ) { @@ -560,14 +555,14 @@ struct image *image_hdf5_read(DataTemplate *dtempl, { ERROR("Failed to load panel data\n"); image_free(image); - return NULL; + return 1; } } image->filename = strdup(filename); image->ev = safe_strdup(event); - return image; + return 0; } -- cgit v1.2.3