From 877543e38be9c3ef7fa0f7888250b8d7f2453da0 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 4 Oct 2012 10:47:14 +0200 Subject: Fix a FIXME --- libcrystfel/src/hdf5-file.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/libcrystfel/src/hdf5-file.c b/libcrystfel/src/hdf5-file.c index 175b3708..18652566 100644 --- a/libcrystfel/src/hdf5-file.c +++ b/libcrystfel/src/hdf5-file.c @@ -672,7 +672,22 @@ void free_copy_hdf5_field_list(struct copy_hdf5_field *n) void add_copy_hdf5_field(struct copy_hdf5_field *copyme, const char *name) { - assert(copyme->n_fields < copyme->max_fields); /* FIXME */ + /* Need more space? */ + if ( copyme->n_fields == copyme->max_fields ) { + + char **nfields; + int nmax = copyme->max_fields + 32; + + nfields = realloc(copyme->fields, nmax*sizeof(char *)); + if ( nfields == NULL ) { + ERROR("Failed to allocate space for new HDF5 field.\n"); + return; + } + + copyme->max_fields = nmax; + copyme->fields = nfields; + + } copyme->fields[copyme->n_fields] = strdup(name); if ( copyme->fields[copyme->n_fields] == NULL ) { -- cgit v1.2.3