aboutsummaryrefslogtreecommitdiff
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
parent5ce139000ebd73bd6897f1a498d5d806af75d51b (diff)
Add crystal_add_notes()
-rw-r--r--libcrystfel/src/crystal.c25
-rw-r--r--libcrystfel/src/crystal.h2
2 files changed, 27 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;
+}
diff --git a/libcrystfel/src/crystal.h b/libcrystfel/src/crystal.h
index 92f60fc3..f0d732ff 100644
--- a/libcrystfel/src/crystal.h
+++ b/libcrystfel/src/crystal.h
@@ -82,6 +82,8 @@ extern void crystal_set_image(Crystal *cryst, struct image *image);
extern void crystal_set_mosaicity(Crystal *cryst, double m);
extern void crystal_set_notes(Crystal *cryst, const char *notes);
+extern void crystal_add_notes(Crystal *cryst, const char *notes_add);
+
#ifdef __cplusplus
}
#endif