diff options
author | Thomas White <taw@bitwiz.org.uk> | 2012-03-13 08:30:52 +0100 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2012-03-13 08:30:52 +0100 |
commit | b85be4dadff2ae755c368400d15318258d0428a5 (patch) | |
tree | 1946ce7ad6bbd3e5e4b0c7082c54ed58df1df088 | |
parent | 895beffcb22f9589805a31e4df93f0ffaabf7843 (diff) |
Fix strange behaviour of add_refl_to_list()
-rw-r--r-- | libcrystfel/src/geometry.c | 2 | ||||
-rw-r--r-- | libcrystfel/src/reflist.c | 56 | ||||
-rw-r--r-- | libcrystfel/src/reflist.h | 2 |
3 files changed, 29 insertions, 31 deletions
diff --git a/libcrystfel/src/geometry.c b/libcrystfel/src/geometry.c index 6a807d3b..218c0fee 100644 --- a/libcrystfel/src/geometry.c +++ b/libcrystfel/src/geometry.c @@ -300,7 +300,7 @@ RefList *find_intersections(struct image *image, UnitCell *cell) asx,asy,asz,bsx,bsy,bsz,csx,csy,csz); if ( refl != NULL ) { - refl = add_refl_to_list(refl, reflections); + add_refl_to_list(refl, reflections); } } diff --git a/libcrystfel/src/reflist.c b/libcrystfel/src/reflist.c index 24550012..cea25bf3 100644 --- a/libcrystfel/src/reflist.c +++ b/libcrystfel/src/reflist.c @@ -803,6 +803,29 @@ static Reflection *insert_node(Reflection *refl, Reflection *new) } +static void add_to_list(RefList *list, Reflection *new, + signed int h, signed int k, signed int l) +{ + Reflection *f; + + f = find_refl(list, h, k, l); + if ( f == NULL ) { + + list->head = insert_node(list->head, new); + list->head->col = BLACK; + + } else { + + /* New reflection is identical to a previous one */ + while ( f->next != NULL ) { + f = f->next; + } + f->next = new; + new->prev = f; + } +} + + /** * add_refl * @list: A %RefList @@ -820,7 +843,6 @@ static Reflection *insert_node(Reflection *refl, Reflection *new) Reflection *add_refl(RefList *list, signed int h, signed int k, signed int l) { Reflection *new; - Reflection *f; assert(abs(h)<256); assert(abs(k)<256); @@ -829,21 +851,7 @@ Reflection *add_refl(RefList *list, signed int h, signed int k, signed int l) new = new_node(SERIAL(h, k, l)); if ( new == NULL ) return NULL; - f = find_refl(list, h, k, l); - if ( f == NULL ) { - - list->head = insert_node(list->head, new); - list->head->col = BLACK; - - } else { - - /* New reflection is identical to a previous one */ - while ( f->next != NULL ) { - f = f->next; - } - f->next = new; - new->prev = f; - } + add_to_list(list, new, h, k, l); return new; } @@ -854,26 +862,16 @@ Reflection *add_refl(RefList *list, signed int h, signed int k, signed int l) * @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. + * Adds a @refl to @list. * **/ -Reflection *add_refl_to_list(Reflection *refl, RefList *list) +void 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; + add_to_list(list, refl, h, k, l); } diff --git a/libcrystfel/src/reflist.h b/libcrystfel/src/reflist.h index c9bb8f0d..246ef885 100644 --- a/libcrystfel/src/reflist.h +++ b/libcrystfel/src/reflist.h @@ -114,7 +114,7 @@ extern void set_symmetric_indices(Reflection *refl, /* Insertion */ extern Reflection *add_refl(RefList *list, signed int h, signed int k, signed int l); -extern Reflection *add_refl_to_list(Reflection *refl, RefList *list); +extern void add_refl_to_list(Reflection *refl, RefList *list); /* Iteration */ extern Reflection *first_refl(RefList *list, RefListIterator **piter); |