aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2021-03-12 15:25:48 +0100
committerThomas White <taw@physics.org>2021-03-12 16:22:32 +0100
commitdf469d21c20e655d66712f78b8054c9e110b62f3 (patch)
tree0126fa02bf17927975c24fbf3035c18e0f14f50d /libcrystfel
parentdfcf29d8df4e55cf6c81cffc11e30b71bc05c0a2 (diff)
FromFile indexer: Remove unnecessary casting/memset
Diffstat (limited to 'libcrystfel')
-rw-r--r--libcrystfel/src/indexers/fromfile.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/libcrystfel/src/indexers/fromfile.c b/libcrystfel/src/indexers/fromfile.c
index cb1fb150..040b35e5 100644
--- a/libcrystfel/src/indexers/fromfile.c
+++ b/libcrystfel/src/indexers/fromfile.c
@@ -71,10 +71,11 @@ struct fromfile_private
void print_struct(struct fromfile_entries *sol_hash)
{
struct fromfile_entries *s;
- s = (struct fromfile_entries *)malloc(sizeof *s);
- memset(s, 0, sizeof *s);
- for( s=sol_hash; s != NULL; s=(struct fromfile_entries*)(s->hh.next) ) {
+ s = calloc(1, sizeof(struct fromfile_entries));
+ if ( s == NULL ) return;
+
+ for( s=sol_hash; s != NULL; s=s->hh.next ) {
printf("File %s, event %s, and crystal_number %d \n",
s->key.filename, s->key.event, s->key.crystal_number);
}
@@ -84,10 +85,10 @@ void print_struct(struct fromfile_entries *sol_hash)
void full_print_struct(struct fromfile_entries *sol_hash)
{
struct fromfile_entries *s;
- s = (struct fromfile_entries *)malloc(sizeof *s);
- memset(s, 0, sizeof *s);
+ s = calloc(1, sizeof(struct fromfile_entries));
+ if ( s == NULL ) return;
- for( s=sol_hash; s != NULL; s=(struct fromfile_entries*)(s->hh.next) ) {
+ for( s=sol_hash; s != NULL; s=s->hh.next ) {
printf("File %s, event %s, and crystal_number %d \n",
s->key.filename, s->key.event,
s->key.crystal_number);
@@ -313,11 +314,10 @@ int fromfile_index(struct image *image, void *mpriv, int crystal_number)
struct fromfile_entries *item, *p, *pprime;
int ncryst = 0;
float *sol;
- struct fromfile_private *dp = (struct fromfile_private *)mpriv;
+ struct fromfile_private *dp = mpriv;
/* Look up the hash table */
- item = (struct fromfile_entries *)malloc(sizeof *item);
- memset(item, 0, sizeof *item);
+ item = calloc(1, sizeof(struct fromfile_entries));
strcpy(item->key.filename, image->filename);
strcpy(item->key.event, get_event_string(image->event));
item->key.crystal_number = crystal_number;