From 0241684ea77e8aa20ad2cb3903589559f4a7b009 Mon Sep 17 00:00:00 2001 From: paul Date: Wed, 26 Oct 2005 05:05:16 +0000 Subject: 2005-10-26 Paul Jakma * (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. --- lib/pqueue.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'lib/pqueue.c') 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 +#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; -- cgit v1.2.1