diff options
author | Thomas White <taw@physics.org> | 2024-01-16 12:03:15 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2024-02-06 16:59:34 +0100 |
commit | 4ad424f132dc3311502567e58b695fecdeb10106 (patch) | |
tree | 94fc0c1fe085de5f7e8553dced1f1b2a235fdf92 /libcrystfel/src/indexers/fromfile.c | |
parent | 5960cc81e3e35e4d38fdd720680c98bef070d695 (diff) |
Use libcrystfel memory allocation routines everywhere
Diffstat (limited to 'libcrystfel/src/indexers/fromfile.c')
-rw-r--r-- | libcrystfel/src/indexers/fromfile.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/libcrystfel/src/indexers/fromfile.c b/libcrystfel/src/indexers/fromfile.c index 1716dd66..c7f1d1ba 100644 --- a/libcrystfel/src/indexers/fromfile.c +++ b/libcrystfel/src/indexers/fromfile.c @@ -101,7 +101,7 @@ struct fromfile_entry *add_unique(struct fromfile_entry **phead, struct fromfile_entry *item; - item = malloc(sizeof(struct fromfile_entry)); + item = cfmalloc(sizeof(struct fromfile_entry)); if ( item == NULL ) return NULL; item->n_crystals = 0; @@ -197,12 +197,12 @@ void *fromfile_prepare(IndexingMethod *indm, struct fromfile_options *opts) if ( opts->filename[0] == '/' ) { fh = fopen(opts->filename, "r"); } else { - char *prefixed_fn = malloc(4+strlen(opts->filename)); + char *prefixed_fn = cfmalloc(4+strlen(opts->filename)); if ( prefixed_fn == NULL ) return NULL; strcpy(prefixed_fn, "../"); strcat(prefixed_fn, opts->filename); fh = fopen(prefixed_fn, "r"); - free(prefixed_fn); + cffree(prefixed_fn); } if ( fh == NULL ) { @@ -210,7 +210,7 @@ void *fromfile_prepare(IndexingMethod *indm, struct fromfile_options *opts) return NULL; } - dp = malloc(sizeof(struct fromfile_private)); + dp = cfmalloc(sizeof(struct fromfile_private)); if ( dp == NULL ) { fclose(fh); return NULL; @@ -305,8 +305,8 @@ void *fromfile_prepare(IndexingMethod *indm, struct fromfile_options *opts) } - for ( i=0; i<n; i++ ) free(bits[i]); - free(bits); + for ( i=0; i<n; i++ ) cffree(bits[i]); + cffree(bits); } while ( 1 ); @@ -360,7 +360,7 @@ void fromfile_cleanup(void *mpriv) } } - free(dp); + cffree(dp); } @@ -376,7 +376,7 @@ static void fromfile_show_help() int fromfile_default_options(struct fromfile_options **opts_ptr) { struct fromfile_options *opts; - opts = malloc(sizeof(struct fromfile_options)); + opts = cfmalloc(sizeof(struct fromfile_options)); if ( opts == NULL ) return ENOMEM; opts->filename = NULL; *opts_ptr = opts; @@ -402,7 +402,7 @@ static error_t fromfile_parse_arg(int key, char *arg, return EINVAL; case 2 : - (*opts_ptr)->filename = strdup(arg); + (*opts_ptr)->filename = cfstrdup(arg); break; default : |