From 5cc0d3bc1f6834b924f6bfad8060513748f09e9d Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Wed, 6 Aug 2008 07:30:10 +0000 Subject: [PATCH] --- ase/include/ase/cmn/sll.h | 48 +++++++++++++++++++++++++++++++++++++++ ase/lib/cmn/sll.c | 28 +++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 ase/include/ase/cmn/sll.h create mode 100644 ase/lib/cmn/sll.c diff --git a/ase/include/ase/cmn/sll.h b/ase/include/ase/cmn/sll.h new file mode 100644 index 00000000..adf6b581 --- /dev/null +++ b/ase/include/ase/cmn/sll.h @@ -0,0 +1,48 @@ +/* + * $Id: map.h 223 2008-06-26 06:44:41Z baconevi $ + * + * {License} + */ + +#ifndef _ASE_CMN_SLL_H_ +#define _ASE_CMN_SLL_H_ + +#include +#include + +/* + * Singly Linked List + */ +typedef struct ase_sll_t ase_sll_t; + +struct ase_sll_t +{ + /* map owner. passed to freeval and sameval as the first argument */ + void* owner; + + ase_sll_node_t* head; + ase_sll_node_t* tail; + + ase_size_t size; + + /* the mmgr pointed at by mmgr should be valid + * while the list is alive as the contents are + * not replicated */ + ase_mmgr_t* mmgr; +}; + +#ifdef __cplusplus +extern "C" { +#endif + +ase_sll_t* ase_sll_open (ase_mmgr_t* mmgr); +void ase_sll_close (ase_sll_t* sll); +void ase_sll_clear (ase_sll_t* sll); + +ase_size_t ase_sll_getsize (ase_sll_t* sll); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/lib/cmn/sll.c b/ase/lib/cmn/sll.c new file mode 100644 index 00000000..bb4f1513 --- /dev/null +++ b/ase/lib/cmn/sll.c @@ -0,0 +1,28 @@ +/* + * $Id$ + * + * {License} + */ + +#include +#include + +ase_sll_t* ase_sll_open (ase_mmgr_t* mmgr) +{ + return ase_sll_openx (mmgr, 0, ASE_NULL); +} + +ase_sll_openx (ase_mmgr_t* mmgr, ase_size_t extension, ase_fuser_t fuser) +{ + ase_sll_t* sll; + + ssll = ASE_MALLOC (mmgr, ASE_SIZEOF(ase_sll_t) + extension); + if (sll == ASE_NULL) return ASE_NULL; + + ase_memset (sll, 0, ASE_SIZEOF(ase_sll_t) + extension); + if (mmgr_fuser) mmgr = fuser (mmgr, sll + 1); + sll->mmgr = mmgr; + + + return mmgr; +}