From dc88e805ff86fed82f53b3a8574ddc7c63e3b1dc Mon Sep 17 00:00:00 2001 From: Valerio Mariani Date: Thu, 10 Jul 2014 10:18:31 +0200 Subject: Multi-event mode bug fixes --- libcrystfel/src/detector.h | 1 + libcrystfel/src/events.c | 2 +- libcrystfel/src/hdf5-file.c | 20 +++++++++++++++++--- 3 files changed, 19 insertions(+), 4 deletions(-) (limited to 'libcrystfel') diff --git a/libcrystfel/src/detector.h b/libcrystfel/src/detector.h index 3fa3c141..e99fb7fc 100644 --- a/libcrystfel/src/detector.h +++ b/libcrystfel/src/detector.h @@ -43,6 +43,7 @@ struct panel; struct badregion; struct detector; struct hdfile; +struct event; #include "hdf5-file.h" #include "image.h" diff --git a/libcrystfel/src/events.c b/libcrystfel/src/events.c index 87c0530d..a6bf9f60 100644 --- a/libcrystfel/src/events.c +++ b/libcrystfel/src/events.c @@ -536,7 +536,7 @@ char *event_path_placeholder_subst(const char * entry, char *full_path; int len_head, len_tail; - full_path = malloc(strlen(data) + strlen(entry)); + full_path = malloc((strlen(data) + strlen(entry)+1)*sizeof(char)); ph_loc = strstr(data, "%"); len_head = ph_loc-data; len_tail = strlen(ph_loc); diff --git a/libcrystfel/src/hdf5-file.c b/libcrystfel/src/hdf5-file.c index df37e77f..c56ad1c6 100644 --- a/libcrystfel/src/hdf5-file.c +++ b/libcrystfel/src/hdf5-file.c @@ -36,6 +36,7 @@ #include #include #include +#include #include "events.h" #include "image.h" @@ -104,6 +105,12 @@ struct hdfile *hdfile_open(const char *filename) f = malloc(sizeof(struct hdfile)); if ( f == NULL ) return NULL; + if ( access( filename, R_OK ) == -1 ) { + ERROR("File does not exists or it cannot be read: %s\n", filename); + free(f); + return NULL; + } + f->fh = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT); if ( f->fh < 0 ) { ERROR("Couldn't open file: %s\n", filename); @@ -119,8 +126,8 @@ struct hdfile *hdfile_open(const char *filename) int hdfile_set_image(struct hdfile *f, const char *path, struct panel *p) { - hsize_t size[2]; - hsize_t max_size[2]; + hsize_t *size; + hsize_t *max_size; hid_t sh; int sh_dim; int di; @@ -150,6 +157,9 @@ int hdfile_set_image(struct hdfile *f, const char *path, } + size = malloc(sh_dim*sizeof(hsize_t)); + max_size = malloc(sh_dim*sizeof(hsize_t)); + H5Sget_simple_extent_dims(sh, size, max_size); H5Sclose(sh); @@ -173,6 +183,9 @@ int hdfile_set_image(struct hdfile *f, const char *path, } + free(size); + free(max_size); + return 0; } @@ -1020,6 +1033,7 @@ int hdf5_read2(struct hdfile *f, struct image *image, } fail = hdfile_set_image(f, panel_full_path, p); + free(panel_full_path); } else { @@ -2031,7 +2045,7 @@ static herr_t parse_file_event_structure(hid_t loc_id, char *name, truncated_path, H5_INDEX_NAME, H5_ITER_NATIVE, NULL, - parse_file_event_structure, + (H5L_iterate_t)parse_file_event_structure, (void *) pp, H5P_DEFAULT); } } -- cgit v1.2.3