aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2010-09-08 10:58:21 +0200
committerThomas White <taw@physics.org>2012-02-22 15:26:57 +0100
commit9526f8c65df5fdb21247b57cd414c258375dc798 (patch)
tree8ae9ed8c1778196992e94a7f73f21b52f353f676
parent52f8c8aa18ca79fb6af5acf458dd22448d0944fc (diff)
Free indexing resources at the end
-rw-r--r--src/index.c13
-rw-r--r--src/index.h2
-rw-r--r--src/indexamajig.c2
-rw-r--r--src/templates.c9
-rw-r--r--src/templates.h2
5 files changed, 28 insertions, 0 deletions
diff --git a/src/index.c b/src/index.c
index 8f563990..16265865 100644
--- a/src/index.c
+++ b/src/index.c
@@ -56,6 +56,19 @@ IndexingPrivate *prepare_indexing(IndexingMethod indm, UnitCell *cell,
}
+void cleanup_indexing(IndexingPrivate *priv)
+{
+ switch ( priv->indm ) {
+ case INDEXING_NONE :
+ break;
+ case INDEXING_DIRAX :
+ break;
+ case INDEXING_TEMPLATE :
+ free_templates(priv);
+ }
+}
+
+
static void write_drx(struct image *image)
{
FILE *fh;
diff --git a/src/index.h b/src/index.h
index 57373469..2e957538 100644
--- a/src/index.h
+++ b/src/index.h
@@ -39,4 +39,6 @@ extern void index_pattern(struct image *image, UnitCell *cell,
IndexingMethod indm, int no_match, int verbose,
IndexingPrivate *priv);
+extern void cleanup_indexing(IndexingPrivate *priv);
+
#endif /* INDEX_H */
diff --git a/src/indexamajig.c b/src/indexamajig.c
index 088d0535..32fb9012 100644
--- a/src/indexamajig.c
+++ b/src/indexamajig.c
@@ -860,6 +860,8 @@ int main(int argc, char *argv[])
}
+ cleanup_indexing(ipriv);
+
free(prefix);
free(det->panels);
free(det);
diff --git a/src/templates.c b/src/templates.c
index 1bc47ff9..765d4324 100644
--- a/src/templates.c
+++ b/src/templates.c
@@ -354,5 +354,14 @@ void match_templates(struct image *image, IndexingPrivate *ipriv)
priv->templates[max_i].omega,
priv->templates[max_i].phi,
rot_best);
+}
+
+
+void free_templates(IndexingPrivate *priv)
+{
+ struct _indexingprivate_template *tpriv
+ = (struct _indexingprivate_template *)priv;
+ free(tpriv->templates);
+ free(tpriv);
}
diff --git a/src/templates.h b/src/templates.h
index 559733fe..50aa7443 100644
--- a/src/templates.h
+++ b/src/templates.h
@@ -27,4 +27,6 @@ extern IndexingPrivate *generate_templates(UnitCell *cell, const char *filename,
extern void match_templates(struct image *image, IndexingPrivate *ipriv);
+extern void free_templates(IndexingPrivate *priv);
+
#endif /* TEMPLATES_H */