added ase_sll_init() and ase_sll_fini()

This commit is contained in:
hyung-hwan 2008-09-01 05:15:57 +00:00
parent 8a219e1548
commit cb5e20a885
2 changed files with 24 additions and 6 deletions

View File

@ -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
*/

View File

@ -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));