From efea4a6586d1b7406beea95ddfc7894cf0e13e72 Mon Sep 17 00:00:00 2001 From: axel Date: Tue, 4 Oct 2005 23:43:26 +1000 Subject: [PATCH] Add shortcut function for creating an array_list_t on the heap darcs-hash:20051004134326-ac50b-91d5006f218f2f9370d239b38d8e88eddc7c0b96.gz --- util.c | 10 ++++++++++ util.h | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/util.c b/util.c index 3ea19ea4e..fe41033c2 100644 --- a/util.c +++ b/util.c @@ -616,6 +616,16 @@ void pq_destroy( priority_queue_t *q ) } +array_list_t *al_new() +{ + array_list_t *res = malloc( sizeof( array_list_t ) ); + if( !res ) + die_mem(); + al_init( res ); + return res; +} + + void al_init( array_list_t *l ) { memset( l, 0, sizeof( array_list_t ) ); diff --git a/util.h b/util.h index ef14fb4f8..3efe47257 100644 --- a/util.h +++ b/util.h @@ -303,6 +303,11 @@ int pq_get_count( priority_queue_t *q ); */ void pq_destroy( priority_queue_t *q ); +/** + Allocate heap memory for creating a new list and initialize it +*/ +array_list_t *al_new() + /** Initialize the list. */ void al_init( array_list_t *l ); /** Destroy the list and free memory used by it.*/