This commit is contained in:
hyung-hwan 2008-08-06 07:30:10 +00:00
parent 961c493986
commit 5cc0d3bc1f
2 changed files with 76 additions and 0 deletions

48
ase/include/ase/cmn/sll.h Normal file
View File

@ -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 <ase/types.h>
#include <ase/macros.h>
/*
* 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

28
ase/lib/cmn/sll.c Normal file
View File

@ -0,0 +1,28 @@
/*
* $Id$
*
* {License}
*/
#include <ase/cmn/sll.h>
#include <ase/cmn/mem.h>
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;
}