diff options
author | Thomas White <taw@physics.org> | 2012-01-20 20:14:01 -0800 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-02-22 15:27:44 +0100 |
commit | 71aa7f6e5bf2cfefa7b6a4e16556eb079b5c762b (patch) | |
tree | d47f8f1ea304479720a3889632c53a312dbe6337 /libcrystfel/src | |
parent | ae51e75490daf47e2deefe83e72a1f5c092fa023 (diff) |
Tidy up and fix stupid bugs (that Valgrind missed...)
Diffstat (limited to 'libcrystfel/src')
-rw-r--r-- | libcrystfel/src/peaks.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/libcrystfel/src/peaks.c b/libcrystfel/src/peaks.c index f1021fdf..0cbce55f 100644 --- a/libcrystfel/src/peaks.c +++ b/libcrystfel/src/peaks.c @@ -553,20 +553,22 @@ static int compare_resolution(const void *av, const void *bv) } static struct integr_ind *sort_reflections(RefList *list, UnitCell *cell, - int *n) + int *np) { struct integr_ind *il; Reflection *refl; RefListIterator *iter; - int i; + int i, n; - *n = num_reflections(list); + n = num_reflections(list); + *np = 0; /* For now */ - if ( *n == 0 ) return NULL; + if ( n == 0 ) return NULL; - il = calloc(*n, sizeof(struct integr_ind)); + il = calloc(n, sizeof(struct integr_ind)); if ( il == NULL ) return NULL; + i = 0; for ( refl = first_refl(list, &iter); refl != NULL; refl = next_refl(refl, iter) ) @@ -584,11 +586,12 @@ static struct integr_ind *sort_reflections(RefList *list, UnitCell *cell, il[i].refl = refl; i++; - assert(i < *n); + assert(i <= n); } - qsort(il, *n, sizeof(struct integr_ind), compare_resolution); + qsort(il, n, sizeof(struct integr_ind), compare_resolution); + *np = n; return il; } |