defined ASE_MEMXXX and started adding copier and freeer
This commit is contained in:
@ -14,32 +14,100 @@
|
||||
* Singly Linked List
|
||||
*/
|
||||
typedef struct ase_sll_t ase_sll_t;
|
||||
typedef struct ase_sll_node_t ase_sll_node_t;
|
||||
|
||||
struct ase_sll_t
|
||||
{
|
||||
/* map owner. passed to freeval and sameval as the first argument */
|
||||
void* owner;
|
||||
typedef void* (*ase_sll_copier_t) (ase_sll_t* sll, void* data, ase_size_t len);
|
||||
typedef void (*ase_sll_freeer_t) (ase_sll_t* sll, void* data, ase_size_t len);
|
||||
typedef int (*ase_sll_walker_t) (ase_sll_t* sll, void* data, ase_size_t len);
|
||||
|
||||
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;
|
||||
};
|
||||
#define ASE_SLL_COPIER_INLINE ase_sll_copyinline
|
||||
|
||||
#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);
|
||||
/*
|
||||
* NAME creates a new singly linked list
|
||||
* RETURNS a pointer to a newly created singly linked list
|
||||
*/
|
||||
ase_sll_t* ase_sll_open (
|
||||
ase_mmgr_t* mmgr /* memory manager */
|
||||
);
|
||||
|
||||
ase_size_t ase_sll_getsize (ase_sll_t* sll);
|
||||
/*
|
||||
* NAME creates a new singly linked list with extension
|
||||
* RETURNS a pointer to a newly created singly linked list
|
||||
*/
|
||||
ase_sll_t* ase_sll_openx (
|
||||
ase_mmgr_t* mmgr /* memory manager */ ,
|
||||
ase_size_t extension /* size of extension in bytes */,
|
||||
ase_fuser_t fuser
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME destroys a singly linked list
|
||||
*/
|
||||
void ase_sll_close (
|
||||
ase_sll_t* sll /* a singly linked list */
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME deletes all elements of a singly linked list
|
||||
*/
|
||||
void ase_sll_clear (
|
||||
ase_sll_t* sll /* a singly linked list */
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME specifies how to clone an element
|
||||
*
|
||||
* DESCRIPTION
|
||||
* A special copier ASE_SLL_COPIER_INLINE is provided. This copier enables
|
||||
* you to copy the data inline to the internal node. No freeer is invoked
|
||||
* when the node is freeed.
|
||||
*
|
||||
* You may set the copier to ASE_NULL to perform no special operation
|
||||
* when the data pointer is rememebered.
|
||||
*/
|
||||
void ase_sll_setcopier (
|
||||
ase_sll_t* sll /* a singly linked list */,
|
||||
ase_sll_copier_t copier /* a element copier */
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME specifies how to destroy an element
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The freeer is called when a node containing the element is destroyed.
|
||||
*/
|
||||
void ase_sll_setfreeer (
|
||||
ase_sll_t* sll /* a singly linked list */,
|
||||
ase_sll_freeer_t freeer /* a element freeer */
|
||||
);
|
||||
|
||||
/*
|
||||
* Returns the pointer to the extension area
|
||||
*/
|
||||
void* ase_sll_getextension (
|
||||
ase_sll_t* sll /* a singly linked list */
|
||||
);
|
||||
|
||||
/*
|
||||
* Gets the number of elements held in a singly linked list
|
||||
* RETURNS the number of elements the list holds
|
||||
*/
|
||||
ase_size_t ase_sll_getsize (
|
||||
ase_sll_t* sll /* a singly linked list */
|
||||
);
|
||||
|
||||
/* Traverses s singly linked list */
|
||||
void ase_sll_walk (ase_sll_t* sll, ase_sll_walker_t walker);
|
||||
|
||||
/*
|
||||
* Causes a singly linked list to copy in data to a node.
|
||||
* Use ASE_SLL_COPIER_INLINE instead.
|
||||
*/
|
||||
void* ase_sll_copyinline (ase_sll_t* sll, void* data, ase_size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Reference in New Issue
Block a user