From aac52ba7017b5644ee51433743abc77146e01117 Mon Sep 17 00:00:00 2001 From: erickson Date: Thu, 2 Mar 2006 19:07:40 +0000 Subject: [PATCH] added method to allow creation of list with a starting size git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@655 9efc2488-bf62-4759-914b-345cdb29e865 --- src/libstack/osrf_list.c | 9 +++++++++ src/libstack/osrf_list.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/src/libstack/osrf_list.c b/src/libstack/osrf_list.c index f04c6ec..9b2de0f 100644 --- a/src/libstack/osrf_list.c +++ b/src/libstack/osrf_list.c @@ -9,6 +9,15 @@ osrfList* osrfNewList() { return list; } +osrfList* osrfNewListSize( unsigned int size ) { + osrfList* list = safe_malloc(sizeof(osrfList)); + list->size = 0; + list->freeItem = NULL; + list->arrsize = size; + list->arrlist = safe_malloc( list->arrsize * sizeof(void*) ); + return list; +} + int osrfListPush( osrfList* list, void* item ) { if(!(list)) return -1; diff --git a/src/libstack/osrf_list.h b/src/libstack/osrf_list.h index 69ced17..e936d1c 100644 --- a/src/libstack/osrf_list.h +++ b/src/libstack/osrf_list.h @@ -28,6 +28,8 @@ struct __osrfListIteratorStruct { }; typedef struct __osrfListIteratorStruct osrfListIterator; +osrfList* osrfNewListSize( unsigned int size ); + /** Creates a new list iterator with the given list -- 2.11.0