diff options
author | Thomas White <taw@physics.org> | 2012-10-04 10:47:14 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-10-04 10:47:14 +0200 |
commit | 877543e38be9c3ef7fa0f7888250b8d7f2453da0 (patch) | |
tree | 69b82cf7186d9618e3917b5add3260dbb5df8858 | |
parent | cf0e84fdf604d0db14f6f52498a01a9175d9bf9a (diff) |
Fix a FIXME
-rw-r--r-- | libcrystfel/src/hdf5-file.c | 17 |
1 files changed, 16 insertions, 1 deletions
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 ) { |