From 93a058920415e2790f9bf9167e094b26074edb8e Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Thu, 7 Aug 2008 07:52:14 +0000 Subject: [PATCH] experimented ase_sll_openx --- ase/lib/cmn/sll.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/ase/lib/cmn/sll.c b/ase/lib/cmn/sll.c index bb4f1513..beb4b485 100644 --- a/ase/lib/cmn/sll.c +++ b/ase/lib/cmn/sll.c @@ -23,6 +23,66 @@ ase_sll_openx (ase_mmgr_t* mmgr, ase_size_t extension, ase_fuser_t fuser) if (mmgr_fuser) mmgr = fuser (mmgr, sll + 1); sll->mmgr = mmgr; - return mmgr; } + +void ase_sll_close (ase_sll_t* sll) +{ + ase_sll_clear (sll); + ASE_FREE (sll->mmgr, sll); +} + +void ase_sll_clear (ase_sll_t* sll) +{ + while (sll->head != ASE_NULL) + { + ase_sll_node_t* n = sll->head->next; + + // 1 + no need to free expli9citly.... + + // 2 + sll->freeer (sll->head->data); + ASE_FREE (sll->mmgr, + + ASE_FREE (sll->mmgr, sll->head); + sll->head = n; + } +} + +void ass_sll_setcopier (ase_sll_t* sll) +{ +} + +void ase_sll_setfreeer (ase_sll_t* sll) +{ +} + +void ase_sll_append (ase_sll_t* sll, void* data) +{ +} + +ase_sll_node_t* ase_sll_prepend (ase_sll_t* sll, void* data, size_t len) +{ + ase_sll_node_t* n; + +// 1 + n = ASE_MALLOC (sll->mmgr, ASE_SIZEOF(ase_sll_node_t) + len); + if (n == ASE_NULL) return ASE_NULL; +// TODO: ASE_MEMCPY to define to be memcpy or ase_memcpy or RtlCopyMemory... + ASE_MEMCPY (n + 1, data, len); + n->data = data; + n->len = len; + +// 2 + n = ASE_MALLOC (sll->mmgr, ASE_SIZEOF(ase_sll_node_t)); + if (n == ASE_NULL) return ASE_NULL; + n->data = sll->copier (data, len); + n->len = len; + + n->next = sll->head; + sll->head = n; + + return n; +} +