diff options
author | Thomas White <taw@physics.org> | 2011-11-09 14:45:58 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-02-22 15:27:39 +0100 |
commit | 667c06f12ca19986acfc00b0bc3adc2ca7f58f58 (patch) | |
tree | 6c0bc218370124d7936d2b25faa1f4d9cb35eb13 /src/reflist.c | |
parent | 22d4f329abdcc91d04ac9cff67112eeeab1509a3 (diff) |
partialator: Use all reflections (not just the ones found the first time around)
Diffstat (limited to 'src/reflist.c')
-rw-r--r-- | src/reflist.c | 59 |
1 files changed, 57 insertions, 2 deletions
diff --git a/src/reflist.c b/src/reflist.c index 33a8d60e..18856c67 100644 --- a/src/reflist.c +++ b/src/reflist.c @@ -162,6 +162,34 @@ RefList *reflist_new() } +/** + * reflection_new: + * @h: The h index of the new reflection + * @k: The k index of the new reflection + * @l: The l index of the new reflection + * + * Creates a new individual reflection. You'll probably want to use + * add_refl_to_list() at some later point. + */ +Reflection *reflection_new(signed int h, signed int k, signed int l) +{ + return new_node(SERIAL(h, k, l)); +} + + +/** + * reflection_free: + * @refl: The reflection to free. + * + * Destroys an individual reflection. + */ +void reflection_free(Reflection *refl) +{ + pthread_mutex_destroy(&refl->lock); + free(refl); +} + + static void recursive_free(Reflection *refl) { if ( refl->child[0] != NULL ) recursive_free(refl->child[0]); @@ -169,8 +197,7 @@ static void recursive_free(Reflection *refl) while ( refl != NULL ) { Reflection *next = refl->next; - pthread_mutex_destroy(&refl->lock); - free(refl); + reflection_free(refl); refl = next; } } @@ -806,6 +833,34 @@ Reflection *add_refl(RefList *list, signed int h, signed int k, signed int l) } +/** + * add_refl_to_list + * @refl: A %Reflection + * @list: A %RefList + * + * Adds a reflection to @list. The reflection that actually gets added will be + * a newly created one, and all the data will be copied across. The original + * reflection will be destroyed and the new reflection returned. + * + * Returns: The newly created reflection, or NULL on failure. + * + **/ +Reflection *add_refl_to_list(Reflection *refl, RefList *list) +{ + signed int h, k, l; + Reflection *r_added; + + get_indices(refl, &h, &k, &l); + r_added = add_refl(list, h, k, l); + if ( r_added == NULL ) return NULL; + + copy_data(r_added, refl); + reflection_free(refl); + + return r_added; +} + + /********************************* Iteration **********************************/ struct _reflistiterator { |