aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/reference/libcrystfel/CrystFEL-sections.txt5
-rw-r--r--libcrystfel/src/crystal.c24
-rw-r--r--libcrystfel/src/crystal.h1
3 files changed, 27 insertions, 3 deletions
diff --git a/doc/reference/libcrystfel/CrystFEL-sections.txt b/doc/reference/libcrystfel/CrystFEL-sections.txt
index eb7ac054..b14f4adc 100644
--- a/doc/reference/libcrystfel/CrystFEL-sections.txt
+++ b/doc/reference/libcrystfel/CrystFEL-sections.txt
@@ -326,9 +326,6 @@ free_beam_parameters
<SECTION>
<FILE>crystal</FILE>
-Crystal
-crystal_new
-crystal_free
</SECTION>
<SECTION>
@@ -357,7 +354,9 @@ get_peaks
<FILE>crystal</FILE>
Crystal
crystal_new
+crystal_copy
crystal_free
+<SUBSECTION>
crystal_get_cell
crystal_get_image
crystal_get_mosaicity
diff --git a/libcrystfel/src/crystal.c b/libcrystfel/src/crystal.c
index 664d933e..02255110 100644
--- a/libcrystfel/src/crystal.c
+++ b/libcrystfel/src/crystal.c
@@ -97,6 +97,30 @@ Crystal *crystal_new()
/**
+ * crystal_copy:
+ * @cryst: A %Crystal to copy.
+ *
+ * Creates a new %Crystal which is a copy of @cryst. The copy is a "shallow
+ * copy", which means that copies are NOT made of the data structures which
+ * @cryst contains references to, for example its %RefList.
+ *
+ * Returns: a (shallow) copy of @cryst, or NULL on failure.
+ *
+ */
+Crystal *crystal_copy(Crystal *cryst)
+{
+ Crystal *c;
+
+ c = crystal_new();
+ if ( c == NULL ) return NULL;
+
+ memcpy(c, cryst, sizeof(Crystal));
+
+ return c;
+}
+
+
+/**
* crystal_free:
* @cryst: A %Crystal to free.
*
diff --git a/libcrystfel/src/crystal.h b/libcrystfel/src/crystal.h
index 3d0ad9d1..8c32a87d 100644
--- a/libcrystfel/src/crystal.h
+++ b/libcrystfel/src/crystal.h
@@ -48,6 +48,7 @@ typedef struct _crystal Crystal;
extern Crystal *crystal_new(void);
+extern Crystal *crystal_copy(Crystal *cryst);
extern void crystal_free(Crystal *cryst);
extern UnitCell *crystal_get_cell(Crystal *cryst);