experimented ase_sll_openx

This commit is contained in:
hyung-hwan 2008-08-07 07:52:14 +00:00
parent 5cc0d3bc1f
commit 93a0589204

View File

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