From 00fa8663bfd35822063750ff12930a2fd8904037 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 2 Sep 2022 11:06:37 +0200 Subject: RefList: assert that a Reflection can only be on one list --- libcrystfel/src/reflist.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'libcrystfel') diff --git a/libcrystfel/src/reflist.c b/libcrystfel/src/reflist.c index d60ee46e..71eda6b2 100644 --- a/libcrystfel/src/reflist.c +++ b/libcrystfel/src/reflist.c @@ -103,6 +103,7 @@ struct _reflection { struct _reflection *next; /* Next and previous in doubly linked */ struct _reflection *prev; /* list of duplicate reflections */ enum _nodecol col; /* Colour (red or black) */ + int in_list; /* If 0, reflection is not in a list */ /* Payload */ pthread_mutex_t lock; /* Protects the contents of "data" */ @@ -126,6 +127,7 @@ static Reflection *new_node(unsigned int serial) new = calloc(1, sizeof(struct _reflection)); if ( new == NULL ) return NULL; + new->in_list = 0; new->serial = serial; new->next = NULL; new->prev = NULL; @@ -895,6 +897,8 @@ static void add_refl_to_list_real(RefList *list, { Reflection *f; + assert(!new->in_list); + f = find_refl(list, h, k, l); if ( f == NULL ) { @@ -910,6 +914,8 @@ static void add_refl_to_list_real(RefList *list, f->next = new; new->prev = f; } + + new->in_list = 1; } -- cgit v1.2.3