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/crystal.c | |
parent | 5960cc81e3e35e4d38fdd720680c98bef070d695 (diff) |
Use libcrystfel memory allocation routines everywhere
Diffstat (limited to 'libcrystfel/src/crystal.c')
-rw-r--r-- | libcrystfel/src/crystal.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/libcrystfel/src/crystal.c b/libcrystfel/src/crystal.c index cece3eb4..e5978795 100644 --- a/libcrystfel/src/crystal.c +++ b/libcrystfel/src/crystal.c @@ -81,7 +81,7 @@ Crystal *crystal_new() { Crystal *cryst; - cryst = malloc(sizeof(Crystal)); + cryst = cfmalloc(sizeof(Crystal)); if ( cryst == NULL ) return NULL; cryst->cell = NULL; @@ -116,7 +116,7 @@ Crystal *crystal_copy(const Crystal *cryst) if ( c == NULL ) return NULL; memcpy(c, cryst, sizeof(Crystal)); - if ( c->notes != NULL ) c->notes = strdup(c->notes); + if ( c->notes != NULL ) c->notes = cfstrdup(c->notes); return c; } @@ -140,7 +140,7 @@ Crystal *crystal_copy_deep(const Crystal *cryst) if ( c == NULL ) return NULL; memcpy(c, cryst, sizeof(Crystal)); - if ( c->notes != NULL ) c->notes = strdup(c->notes); + if ( c->notes != NULL ) c->notes = cfstrdup(c->notes); if ( cryst->cell != NULL ) { UnitCell *cell; @@ -169,8 +169,8 @@ Crystal *crystal_copy_deep(const Crystal *cryst) void crystal_free(Crystal *cryst) { if ( cryst == NULL ) return; - free(cryst->notes); - free(cryst); + cffree(cryst->notes); + cffree(cryst); } @@ -322,8 +322,8 @@ void crystal_set_mosaicity(Crystal *cryst, double m) void crystal_set_notes(Crystal *cryst, const char *notes) { - free(cryst->notes); /* free(NULL) is OK */ - cryst->notes = strdup(notes); + cffree(cryst->notes); /* free(NULL) is OK */ + cryst->notes = cfstrdup(notes); } @@ -338,7 +338,7 @@ void crystal_add_notes(Crystal *cryst, const char *notes_add) } len = strlen(notes_add) + strlen(cryst->notes) + 2; - nnotes = malloc(len); + nnotes = cfmalloc(len); if ( nnotes == NULL ) { ERROR("Failed to add notes to crystal.\n"); return; @@ -347,7 +347,7 @@ void crystal_add_notes(Crystal *cryst, const char *notes_add) strcpy(nnotes, cryst->notes); strcat(nnotes, "\n"); strcat(nnotes, notes_add); - free(cryst->notes); + cffree(cryst->notes); cryst->notes = nnotes; } |