diff options
-rw-r--r-- | src/allocators-store.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/allocators-store.c b/src/allocators-store.c index bfab989..9c5b76b 100644 --- a/src/allocators-store.c +++ b/src/allocators-store.c @@ -84,11 +84,6 @@ _sum_allocators_cmp_by_size (gconstpointer A, gconstpointer B) const struct _sum_allocator * const *aa = A, * const *bb = B; const struct _sum_allocator *a = *aa, *b = *bb; - if (b->size == 0) - return 1; - if (a->size == 0) - return -1; - /* beware integer overflow! */ if (b->size > a->size) return 1; @@ -105,6 +100,11 @@ _sum_allocators_cmp_by_size (gconstpointer A, gconstpointer B) else if (b->n_pages < a->n_pages) return -1; + if (b->size == 0) + return -1; + if (a->size == 0) + return 1; + return b->n_pages * 4096 / b->size * b->count - a->n_pages * 4096 / a->size * a->count; } @@ -114,11 +114,6 @@ _sum_allocators_cmp_by_count (gconstpointer A, gconstpointer B) const struct _sum_allocator * const *aa = A, * const *bb = B; const struct _sum_allocator *a = *aa, *b = *bb; - if (b->size == 0) - return 1; - if (a->size == 0) - return -1; - /* beware integer overflow! */ if (b->count > a->count) return 1; @@ -135,6 +130,11 @@ _sum_allocators_cmp_by_count (gconstpointer A, gconstpointer B) else if (b->size < a->size) return -1; + if (b->size == 0) + return -1; + if (a->size == 0) + return 1; + return b->n_pages * 4096 / b->size * b->count - a->n_pages * 4096 / a->size * a->count; } |