[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#6600: [PATCH] sort: add --threads option to parallelize internal sor
From: |
Pádraig Brady |
Subject: |
bug#6600: [PATCH] sort: add --threads option to parallelize internal sort. |
Date: |
Tue, 13 Jul 2010 10:13:40 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3 |
Here's a small cleanup I missed.
Alternatively one could make heap() return NULL rather than aborting,
but since it already used xmalloc, I'm tending to this..
commit cec33eb226df63f406f7eb70cd46d960ee02a060
Author: Pádraig Brady <address@hidden>
Date: Tue Jul 13 08:23:52 2010 +0100
maint: heap.c: simplify heap_alloc
* gl/lib/heap.c (heap_alloc): Use the fact that the xalloc
routines will not return NULL. Also remove the redundant
temporary variables.
diff --git a/gl/lib/heap.c b/gl/lib/heap.c
index a37224f..f148434 100644
--- a/gl/lib/heap.c
+++ b/gl/lib/heap.c
@@ -36,22 +36,12 @@ static void heapify_up (void **, size_t,
struct heap *
heap_alloc (int (*compare)(const void *, const void *), size_t n_reserve)
{
- struct heap *heap;
- void *xmalloc_ret = xmalloc (sizeof *heap);
- heap = (struct heap *) xmalloc_ret;
- if (!heap)
- return NULL;
+ struct heap *heap = xmalloc (sizeof *heap);
- if (n_reserve <= 0)
+ if (n_reserve == 0)
n_reserve = 1;
- xmalloc_ret = xmalloc (n_reserve * sizeof *(heap->array));
- heap->array = (void **) xmalloc_ret;
- if (!heap->array)
- {
- free (heap);
- return NULL;
- }
+ heap->array = xmalloc (n_reserve * sizeof *(heap->array));
heap->array[0] = NULL;
heap->capacity = n_reserve;
@@ -84,8 +74,7 @@ heap_insert (struct heap *heap, void *item)
if (heap->capacity - 1 <= heap->count)
{
size_t new_size = (2 + heap->count) * sizeof *(heap->array);
- void *realloc_ret = xrealloc (heap->array, new_size);
- heap->array = (void **) realloc_ret;
+ heap->array = xrealloc (heap->array, new_size);
- bug#6600: [PATCH] sort: add --threads option to parallelize internal sort., Pádraig Brady, 2010/07/09
- bug#6600: [PATCH] sort: add --threads option to parallelize internal sort., Paul Eggert, 2010/07/09
- bug#6600: [PATCH] sort: add --threads option to parallelize internal sort., Chen Guo, 2010/07/10
- bug#6600: [PATCH] sort: add --threads option to parallelize internal sort., Pádraig Brady, 2010/07/10
- bug#6600: [PATCH] sort: add --threads option to parallelize internal sort., Pádraig Brady, 2010/07/12
- bug#6600: [PATCH] sort: add --threads option to parallelize internal sort.,
Pádraig Brady <=
- bug#6600: [PATCH] sort: add --threads option to parallelize internal sort., Jim Meyering, 2010/07/13
- bug#6600: [PATCH] sort: add --threads option to parallelize internal sort., Pádraig Brady, 2010/07/13
- bug#6600: [PATCH] sort: add --threads option to parallelize internal sort., Jim Meyering, 2010/07/13
- bug#6600: [PATCH] sort: add --threads option to parallelize internal sort., Chen Guo, 2010/07/13
- bug#6600: [PATCH] sort: add --threads option to parallelize internal sort., Pádraig Brady, 2010/07/14
- bug#6600: [PATCH] sort: add --threads option to parallelize internal sort., Pádraig Brady, 2010/07/15
- bug#6600: [PATCH] sort: add --threads option to parallelize internal sort., Jim Meyering, 2010/07/15
- bug#6600: [PATCH] sort: add --threads option to parallelize internal sort., Chen Guo, 2010/07/21
- bug#6600: [PATCH] sort: add --threads option to parallelize internal sort., Pádraig Brady, 2010/07/21