diff options
author | paul <paul> | 2005-10-26 05:05:16 +0000 |
---|---|---|
committer | paul <paul> | 2005-10-26 05:05:16 +0000 |
commit | 0241684ea77e8aa20ad2cb3903589559f4a7b009 (patch) | |
tree | 2bb64a53f5d8c1091839be9e1afb6e4625828f38 /lib/pqueue.c | |
parent | 216565ab68148d3161422c0d73730614bfeccd7c (diff) |
2005-10-26 Paul Jakma <paul.jakma@sun.com>
* (general) Cleanup a some calls to XFREE,strdup, etc. to use
the memory.h macros.
* memtypes.c: Add MTYPE_IF_RMAP_NAME, MTYPE_PQUEUE,
MTYPE_PQUEUE_DATA and MTYPE_HOST.
* memtypes.h: update auto-built file.
* if_rmap.c: Use MTYPE_IF_RMAP_NAME.
* pqueue.c: Use the two MTYPE_PQUEUE mtypes for allocations.
Diffstat (limited to 'lib/pqueue.c')
-rw-r--r-- | lib/pqueue.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/pqueue.c b/lib/pqueue.c index 2bbafe7c..a974a49e 100644 --- a/lib/pqueue.c +++ b/lib/pqueue.c @@ -20,6 +20,7 @@ Boston, MA 02111-1307, USA. */ #include <zebra.h> +#include "memory.h" #include "pqueue.h" /* priority queue using heap sort */ @@ -110,12 +111,10 @@ pqueue_create (void) { struct pqueue *queue; - queue = (struct pqueue *) malloc (sizeof (struct pqueue)); - memset (queue, 0, sizeof (struct pqueue)); + queue = XCALLOC (MTYPE_PQUEUE, sizeof (struct pqueue)); - queue->array = (void **) - malloc (DATA_SIZE * PQUEUE_INIT_ARRAYSIZE); - memset (queue->array, 0, DATA_SIZE * PQUEUE_INIT_ARRAYSIZE); + queue->array = XCALLOC (MTYPE_PQUEUE_DATA, + DATA_SIZE * PQUEUE_INIT_ARRAYSIZE); queue->array_size = PQUEUE_INIT_ARRAYSIZE; /* By default we want nothing to happen when a node changes. */ @@ -126,8 +125,8 @@ pqueue_create (void) void pqueue_delete (struct pqueue *queue) { - free (queue->array); - free (queue); + XFREE (MTYPE_PQUEUE_DATA, queue->array); + XFREE (MTYPE_PQUEUE, queue); } static int @@ -135,14 +134,13 @@ pqueue_expand (struct pqueue *queue) { void **newarray; - newarray = (void **) malloc (queue->array_size * DATA_SIZE * 2); + newarray = XCALLOC (MTYPE_PQUEUE_DATA, queue->array_size * DATA_SIZE * 2); if (newarray == NULL) return 0; - memset (newarray, 0, queue->array_size * DATA_SIZE * 2); memcpy (newarray, queue->array, queue->array_size * DATA_SIZE); - free (queue->array); + XFREE (MTYPE_PQUEUE_DATA, queue->array); queue->array = newarray; queue->array_size *= 2; |