aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/crystal.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2015-03-29 08:02:45 -0700
committerThomas White <taw@physics.org>2015-04-01 09:33:11 +0200
commita1f41743c249d280a4dc56c6433b6b5817388934 (patch)
tree8f4347ecb04e262e202d9b0d3fdddfe2ac8b69d5 /libcrystfel/src/crystal.c
parent5ce139000ebd73bd6897f1a498d5d806af75d51b (diff)
Add crystal_add_notes()
Diffstat (limited to 'libcrystfel/src/crystal.c')
-rw-r--r--libcrystfel/src/crystal.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/libcrystfel/src/crystal.c b/libcrystfel/src/crystal.c
index 91c3fd52..3c52ddd7 100644
--- a/libcrystfel/src/crystal.c
+++ b/libcrystfel/src/crystal.c
@@ -291,3 +291,28 @@ void crystal_set_notes(Crystal *cryst, const char *notes)
free(cryst->notes); /* free(NULL) is OK */
cryst->notes = strdup(notes);
}
+
+
+void crystal_add_notes(Crystal *cryst, const char *notes_add)
+{
+ size_t len;
+ char *nnotes;
+
+ if ( cryst->notes == NULL ) {
+ crystal_set_notes(cryst, notes_add);
+ return;
+ }
+
+ len = strlen(notes_add) + strlen(cryst->notes) + 2;
+ nnotes = malloc(len);
+ if ( nnotes == NULL ) {
+ ERROR("Failed to add notes to crystal.\n");
+ return;
+ }
+
+ strcpy(nnotes, cryst->notes);
+ strcat(nnotes, "\n");
+ strcat(nnotes, notes_add);
+ free(cryst->notes);
+ cryst->notes = nnotes;
+}