The xtype C Library, Version 1.00
The XLIST Type
Contents:
- xlappend
- xlbehead
- xldata
- xldelete
- xldequeue
- xlend
- xlenqueue
- xlfree
- xlget
- xllen
- xlnew
- xlnext
- xlpop
- xlprepend
- xlprev
- xlpush
- xlrewind
- xlsize
XLIST *xlappend(XLIST *xl, void *p, int s)
Function
Append a node to the list pointed to by xl. The new node will contained the
data in a buffer of size s pointed to by p.
Returns
- NULL, if there was a memory allocation failure.
- xl, otherwise.
void *xlbehead(XLIST *xl, void *p)
Function
Delete the head of the list pointed to by xl, copying the data in it into the
buffer pointed to by p if p is not NULL. The list cursor will point to the new
head of the list.
Returns
void *xldata(XLIST *xl)
Function
Obtain a pointer to the data contained in the current node of the list pointed
to by xl.
Returns
- a pointer to the current data of xl
void xldelete(XLIST *xl)
Function
Delete the current node of the list pointed to by xl.
void *xldequeue(XLIST *xl, void *p)
Function
Pseudonym for xlbehead().
int xlend(XLIST *xl)
Function
Test the list pointed to by xl to see if its cursor is at the end of the list.
xlend() is implemented as a macro.
Returns
- 0, if xl's cursor is not at the end of the list
- non-zero, if xl's cursor is at the end of the list
XLIST *xlenqueue(XLIST *xl, void *p, int s)
Function
Pseudonym for xlappend().
void xlfree(XLIST *xl)
Function
De-allocate the memory used by the list pointed to by xl. xlfree() frees the
memory used by the XLIST structure itself; if the node elements are pointers
to dynamically-allocated objects, these must be freed separately. Do not use
xl after calling this function.
void *xlget(XLIST *xl, void *p)
Function
Copy the data in the current node of the list pointed to by xl into a buffer
pointed to by p.
Returns
int xllen(XLIST *xl)
Function
Compute the length of the list pointed to by xl. xllen() is implemented as a
macro.
Returns
- the number of nodes in the list pointed to by xl.
XLIST *xlnew(void)
Function
Create a new linked list. The new list can be freed by calling xlfree().
Returns
- NULL, if there is a memory allocation failure.
- a pointer to a new list, otherwise.
void *xlnext(XLIST *xl)
Function
Advance the cursor of the list pointed to by xl by one node.
Returns
- NULL, if there are no more nodes in the list.
- a pointer to the next node's data (as xldata()), otherwise.
void *xlpop(XLIST *xl, void *p)
Function
Pseudonym for xlbehead().
XLIST *xlprepend(XLIST *xl, void *p, int s)
Function
Add a new node to the start of the list pointed to by xl. The new node will
contained the data in a buffer of size s pointed to by p.
Returns
- NULL, if there was a memory allocation failure.
- xl, otherwise
void *xlprev(XLIST *xl)
Function
Move the cursor of the list pointed to by xl back one node.
Returns
- NULL, if we tried to move before the head of the list.
- a pointer to the data in the previous node (as xldata()), otherwise.
XLIST *xlpush(XLIST *xl, void *p, int s)
Function
Pseudonym for xlprepend().
void *xlrewind(XLIST *xl)
Function
Move the cursor of the list pointed to by xl to the head of the list.
Returns
- NULL, if the list is empty
- a pointer to the data in the head node (as xldata()), otherwise.
int xlsize(XLIST *xl)
Function
Return the size of the data element in the current node of the list pointed
to by xl.
Returns
- the size (in bytes) of the current data element of xl.