From cb5e20a885a6f2bb06325cf67fc3a0d0fdfc068b Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Mon, 1 Sep 2008 05:15:57 +0000 Subject: [PATCH] added ase_sll_init() and ase_sll_fini() --- ase/include/ase/cmn/sll.h | 9 +++++++++ ase/lib/cmn/sll.c | 21 +++++++++++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/ase/include/ase/cmn/sll.h b/ase/include/ase/cmn/sll.h index b3c2f5d9..e68a27d1 100644 --- a/ase/include/ase/cmn/sll.h +++ b/ase/include/ase/cmn/sll.h @@ -101,6 +101,15 @@ void ase_sll_close ( ase_sll_t* sll /* a singly linked list */ ); +ase_sll_t* ase_sll_init ( + ase_sll_t* sll /* an uninitialized singly linked list */, + ase_mmgr_t* mmgr /* memory manager */ +); + +void ase_sll_fini ( + ase_sll_t* sll /* a singly linked list */ +); + /* * NAME: deletes all elements of a singly linked list */ diff --git a/ase/lib/cmn/sll.c b/ase/lib/cmn/sll.c index 41fb0bff..c77183f6 100644 --- a/ase/lib/cmn/sll.c +++ b/ase/lib/cmn/sll.c @@ -41,19 +41,28 @@ sll_t* ase_sll_open (mmgr_t* mmgr, size_t ext) sll = ASE_MMGR_ALLOC (mmgr, ASE_SIZEOF(sll_t) + ext); if (sll == ASE_NULL) return ASE_NULL; - /* do not zero out the extension */ - ASE_MEMSET (sll, 0, ASE_SIZEOF(sll_t)); - sll->mmgr = mmgr; - - return sll; + return ase_sll_init (sll, mmgr); } void ase_sll_close (sll_t* sll) { - ase_sll_clear (sll); + ase_sll_fini (sll); ASE_MMGR_FREE (sll->mmgr, sll); } +sll_t* ase_sll_init (sll_t* sll, mmgr_t* mmgr) +{ + /* do not zero out the extension */ + ASE_MEMSET (sll, 0, ASE_SIZEOF(sll_t)); + sll->mmgr = mmgr; + return sll; +} + +void ase_sll_fini (sll_t* sll) +{ + ase_sll_clear (sll); +} + void ase_sll_clear (sll_t* sll) { while (HEAD(sll) != ASE_NULL) ase_sll_delete (sll, HEAD(sll));