Style: prototypes, un-register and remove some empty lines.
This commit is contained in:
parent
fb5885af37
commit
3514b3b581
@ -56,6 +56,11 @@ __FBSDID("$FreeBSD$");
|
||||
* Results:
|
||||
* SUCCESS if all went well.
|
||||
*
|
||||
* Arguments:
|
||||
* l affected list
|
||||
* ln node after which to append the datum
|
||||
* d said datum
|
||||
*
|
||||
* Side Effects:
|
||||
* A new ListNode is created and linked in to the List. The lastPtr
|
||||
* field of the List will be altered if ln is the last node in the
|
||||
@ -65,14 +70,11 @@ __FBSDID("$FreeBSD$");
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
ReturnStatus
|
||||
Lst_Append (l, ln, d)
|
||||
Lst l; /* affected list */
|
||||
LstNode ln; /* node after which to append the datum */
|
||||
void * d; /* said datum */
|
||||
Lst_Append (Lst l, LstNode ln, void *d)
|
||||
{
|
||||
register List list;
|
||||
register ListNode lNode;
|
||||
register ListNode nLNode;
|
||||
List list;
|
||||
ListNode lNode;
|
||||
ListNode nLNode;
|
||||
|
||||
if (LstValid (l) && (ln == NULL && LstIsEmpty (l))) {
|
||||
goto ok;
|
||||
@ -113,4 +115,3 @@ Lst_Append (l, ln, d)
|
||||
|
||||
return (SUCCESS);
|
||||
}
|
||||
|
||||
|
@ -56,17 +56,19 @@ __FBSDID("$FreeBSD$");
|
||||
* Results:
|
||||
* SUCCESS if life is good.
|
||||
*
|
||||
* Arguments:
|
||||
* l List to which to add the datum
|
||||
* d Datum to add
|
||||
*
|
||||
* Side Effects:
|
||||
* A new ListNode is created and added to the list.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
ReturnStatus
|
||||
Lst_AtEnd (l, d)
|
||||
Lst l; /* List to which to add the datum */
|
||||
void * d; /* Datum to add */
|
||||
Lst_AtEnd(Lst l, void *d)
|
||||
{
|
||||
register LstNode end;
|
||||
LstNode end;
|
||||
|
||||
end = Lst_Last (l);
|
||||
return (Lst_Append (l, end, d));
|
||||
|
@ -63,11 +63,9 @@ __FBSDID("$FreeBSD$");
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
ReturnStatus
|
||||
Lst_AtFront (l, d)
|
||||
Lst l;
|
||||
void * d;
|
||||
Lst_AtFront(Lst l, void *d)
|
||||
{
|
||||
register LstNode front;
|
||||
LstNode front;
|
||||
|
||||
front = Lst_First (l);
|
||||
return (Lst_Insert (l, front, d));
|
||||
|
@ -61,16 +61,18 @@ __FBSDID("$FreeBSD$");
|
||||
* Results:
|
||||
* None.
|
||||
*
|
||||
* Arguments:
|
||||
* l The list to close
|
||||
*
|
||||
* Side Effects:
|
||||
* The list is closed.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Lst_Close (l)
|
||||
Lst l; /* The list to close */
|
||||
Lst_Close(Lst l)
|
||||
{
|
||||
register List list = (List) l;
|
||||
List list = (List) l;
|
||||
|
||||
if (LstValid(l) == TRUE) {
|
||||
list->isOpen = FALSE;
|
||||
|
@ -61,23 +61,25 @@ __FBSDID("$FreeBSD$");
|
||||
* Results:
|
||||
* SUCCESS if all went well. FAILURE otherwise.
|
||||
*
|
||||
* Arguments:
|
||||
* l1 The list to which l2 is to be appended
|
||||
* l2 The list to append to l1
|
||||
* flags LST_CONCNEW if LstNode's should be duplicated
|
||||
* LST_CONCLINK if should just be relinked
|
||||
*
|
||||
* Side Effects:
|
||||
* New elements are created and appended the the first list.
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
ReturnStatus
|
||||
Lst_Concat (l1, l2, flags)
|
||||
Lst l1; /* The list to which l2 is to be appended */
|
||||
Lst l2; /* The list to append to l1 */
|
||||
int flags; /* LST_CONCNEW if LstNode's should be duplicated
|
||||
* LST_CONCLINK if should just be relinked */
|
||||
Lst_Concat(Lst l1, Lst l2, int flags)
|
||||
{
|
||||
register ListNode ln; /* original LstNode */
|
||||
register ListNode nln; /* new LstNode */
|
||||
register ListNode last; /* the last element in the list. Keeps
|
||||
ListNode ln; /* original LstNode */
|
||||
ListNode nln; /* new LstNode */
|
||||
ListNode last; /* the last element in the list. Keeps
|
||||
* bookkeeping until the end */
|
||||
register List list1 = (List)l1;
|
||||
register List list2 = (List)l2;
|
||||
List list1 = (List)l1;
|
||||
List list2 = (List)l2;
|
||||
|
||||
if (!LstValid (l1) || !LstValid (l2)) {
|
||||
return (FAILURE);
|
||||
@ -176,4 +178,3 @@ Lst_Concat (l1, l2, flags)
|
||||
|
||||
return (SUCCESS);
|
||||
}
|
||||
|
||||
|
@ -62,13 +62,12 @@ __FBSDID("$FreeBSD$");
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void *
|
||||
Lst_Datum (ln)
|
||||
LstNode ln;
|
||||
Lst_Datum(LstNode ln)
|
||||
{
|
||||
|
||||
if (ln != NULL) {
|
||||
return (((ListNode)ln)->datum);
|
||||
} else {
|
||||
return ((void *) NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,11 +63,10 @@ __FBSDID("$FreeBSD$");
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void *
|
||||
Lst_DeQueue (l)
|
||||
Lst l;
|
||||
Lst_DeQueue(Lst l)
|
||||
{
|
||||
void * rd;
|
||||
register ListNode tln;
|
||||
void * rd;
|
||||
ListNode tln;
|
||||
|
||||
tln = (ListNode) Lst_First (l);
|
||||
if (tln == NULL) {
|
||||
@ -81,4 +80,3 @@ Lst_DeQueue (l)
|
||||
return (rd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,13 +64,11 @@ __FBSDID("$FreeBSD$");
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Lst_Destroy (l, freeProc)
|
||||
Lst l;
|
||||
register void (*freeProc)(void *);
|
||||
Lst_Destroy(Lst l, void (*freeProc)(void *))
|
||||
{
|
||||
register ListNode ln;
|
||||
register ListNode tln = NULL;
|
||||
register List list = (List)l;
|
||||
ListNode ln;
|
||||
ListNode tln = NULL;
|
||||
List list = (List)l;
|
||||
|
||||
if (l == NULL || ! l) {
|
||||
/*
|
||||
|
@ -58,19 +58,20 @@ __FBSDID("$FreeBSD$");
|
||||
* Results:
|
||||
* The new Lst structure or NULL if failure.
|
||||
*
|
||||
* Arguments:
|
||||
* l the list to duplicate
|
||||
* copyProc A function to duplicate each void
|
||||
*
|
||||
* Side Effects:
|
||||
* A new list is created.
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
Lst
|
||||
Lst_Duplicate (l, copyProc)
|
||||
Lst l; /* the list to duplicate */
|
||||
/* A function to duplicate each void * */
|
||||
void * (*copyProc)(void *);
|
||||
Lst_Duplicate(Lst l, void *(*copyProc)(void *))
|
||||
{
|
||||
register Lst nl;
|
||||
register ListNode ln;
|
||||
register List list = (List)l;
|
||||
Lst nl;
|
||||
ListNode ln;
|
||||
List list = (List)l;
|
||||
|
||||
if (!LstValid (l)) {
|
||||
return (NULL);
|
||||
|
@ -63,14 +63,12 @@ __FBSDID("$FreeBSD$");
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
ReturnStatus
|
||||
Lst_EnQueue (l, d)
|
||||
Lst l;
|
||||
void * d;
|
||||
Lst_EnQueue(Lst l, void *d)
|
||||
{
|
||||
|
||||
if (LstValid (l) == FALSE) {
|
||||
return (FAILURE);
|
||||
}
|
||||
|
||||
return (Lst_Append (l, Lst_Last(l), d));
|
||||
}
|
||||
|
||||
|
@ -63,11 +63,8 @@ __FBSDID("$FreeBSD$");
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
LstNode
|
||||
Lst_Find (l, d, cProc)
|
||||
Lst l;
|
||||
void * d;
|
||||
int (*cProc)(void *, void *);
|
||||
Lst_Find(Lst l, void *d, int (*cProc)(void *, void *))
|
||||
{
|
||||
|
||||
return (Lst_FindFrom (l, Lst_First(l), d, cProc));
|
||||
}
|
||||
|
||||
|
@ -64,14 +64,10 @@ __FBSDID("$FreeBSD$");
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
LstNode
|
||||
Lst_FindFrom (l, ln, d, cProc)
|
||||
Lst l;
|
||||
register LstNode ln;
|
||||
register void * d;
|
||||
register int (*cProc)(void *, void *);
|
||||
Lst_FindFrom(Lst l, LstNode ln, void *d, int (*cProc)(void *, void *))
|
||||
{
|
||||
register ListNode tln;
|
||||
Boolean found = FALSE;
|
||||
ListNode tln;
|
||||
Boolean found = FALSE;
|
||||
|
||||
if (!LstValid (l) || LstIsEmpty (l) || !LstNodeValid (ln, l)) {
|
||||
return (NULL);
|
||||
@ -94,4 +90,3 @@ Lst_FindFrom (l, ln, d, cProc)
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,13 +62,12 @@ __FBSDID("$FreeBSD$");
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
LstNode
|
||||
Lst_First (l)
|
||||
Lst l;
|
||||
Lst_First(Lst l)
|
||||
{
|
||||
|
||||
if (!LstValid (l) || LstIsEmpty (l)) {
|
||||
return (NULL);
|
||||
} else {
|
||||
return ((LstNode)((List)l)->firstPtr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,13 +63,9 @@ __FBSDID("$FreeBSD$");
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
/*VARARGS2*/
|
||||
void
|
||||
Lst_ForEach (l, proc, d)
|
||||
Lst l;
|
||||
register int (*proc)(void *, void *);
|
||||
register void * d;
|
||||
Lst_ForEach(Lst l, int (*proc)(void *, void *), void *d)
|
||||
{
|
||||
|
||||
Lst_ForEachFrom(l, Lst_First(l), proc, d);
|
||||
}
|
||||
|
||||
|
@ -64,19 +64,14 @@ __FBSDID("$FreeBSD$");
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
/*VARARGS2*/
|
||||
void
|
||||
Lst_ForEachFrom (l, ln, proc, d)
|
||||
Lst l;
|
||||
LstNode ln;
|
||||
register int (*proc)(void *, void *);
|
||||
register void * d;
|
||||
Lst_ForEachFrom(Lst l, LstNode ln, int (*proc)(void *, void *), void *d)
|
||||
{
|
||||
register ListNode tln = (ListNode)ln;
|
||||
register List list = (List)l;
|
||||
register ListNode next;
|
||||
Boolean done;
|
||||
int result;
|
||||
ListNode tln = (ListNode)ln;
|
||||
List list = (List)l;
|
||||
ListNode next;
|
||||
Boolean done;
|
||||
int result;
|
||||
|
||||
if (!LstValid (list) || LstIsEmpty (list)) {
|
||||
return;
|
||||
@ -110,6 +105,4 @@ Lst_ForEachFrom (l, ln, proc, d)
|
||||
}
|
||||
tln = next;
|
||||
} while (!result && !LstIsEmpty(list) && !done);
|
||||
|
||||
}
|
||||
|
||||
|
@ -56,16 +56,18 @@ __FBSDID("$FreeBSD$");
|
||||
* Results:
|
||||
* The created list.
|
||||
*
|
||||
* Arguments:
|
||||
* circ TRUE if the list should be made circular
|
||||
*
|
||||
* Side Effects:
|
||||
* A list is created, what else?
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
Lst
|
||||
Lst_Init(circ)
|
||||
Boolean circ; /* TRUE if the list should be made circular */
|
||||
Lst_Init(Boolean circ)
|
||||
{
|
||||
register List nList;
|
||||
List nList;
|
||||
|
||||
PAlloc (nList, List);
|
||||
|
||||
|
@ -57,6 +57,10 @@ __FBSDID("$FreeBSD$");
|
||||
* Results:
|
||||
* SUCCESS or FAILURE.
|
||||
*
|
||||
* l list to manipulate
|
||||
* ln node before which to insert d
|
||||
* d datum to be inserted
|
||||
*
|
||||
* Side Effects:
|
||||
* the firstPtr field will be changed if ln is the first node in the
|
||||
* list.
|
||||
@ -64,15 +68,11 @@ __FBSDID("$FreeBSD$");
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
ReturnStatus
|
||||
Lst_Insert (l, ln, d)
|
||||
Lst l; /* list to manipulate */
|
||||
LstNode ln; /* node before which to insert d */
|
||||
void * d; /* datum to be inserted */
|
||||
Lst_Insert(Lst l, LstNode ln, void *d)
|
||||
{
|
||||
register ListNode nLNode; /* new lnode for d */
|
||||
register ListNode lNode = (ListNode)ln;
|
||||
register List list = (List)l;
|
||||
|
||||
ListNode nLNode; /* new lnode for d */
|
||||
ListNode lNode = (ListNode)ln;
|
||||
List list = (List)l;
|
||||
|
||||
/*
|
||||
* check validity of arguments
|
||||
@ -113,4 +113,3 @@ Lst_Insert (l, ln, d)
|
||||
|
||||
return (SUCCESS);
|
||||
}
|
||||
|
||||
|
@ -73,12 +73,10 @@ __FBSDID("$FreeBSD$");
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
Boolean
|
||||
Lst_IsAtEnd (l)
|
||||
Lst l;
|
||||
Lst_IsAtEnd(Lst l)
|
||||
{
|
||||
register List list = (List) l;
|
||||
List list = (List) l;
|
||||
|
||||
return (!LstValid (l) || !list->isOpen ||
|
||||
(list->atEnd == Head) || (list->atEnd == Tail));
|
||||
}
|
||||
|
||||
|
@ -64,9 +64,8 @@ __FBSDID("$FreeBSD$");
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
Boolean
|
||||
Lst_IsEmpty (l)
|
||||
Lst l;
|
||||
Lst_IsEmpty(Lst l)
|
||||
{
|
||||
|
||||
return ( ! LstValid (l) || LstIsEmpty(l));
|
||||
}
|
||||
|
||||
|
@ -49,12 +49,10 @@ __FBSDID("$FreeBSD$");
|
||||
#include "lstInt.h"
|
||||
|
||||
LstNode
|
||||
Lst_Member (l, d)
|
||||
Lst l;
|
||||
void * d;
|
||||
Lst_Member(Lst l, void *d)
|
||||
{
|
||||
List list = (List) l;
|
||||
register ListNode lNode;
|
||||
List list = (List) l;
|
||||
ListNode lNode;
|
||||
|
||||
lNode = list->firstPtr;
|
||||
if (lNode == NULL) {
|
||||
|
@ -69,11 +69,10 @@ __FBSDID("$FreeBSD$");
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
LstNode
|
||||
Lst_Next (l)
|
||||
Lst l;
|
||||
Lst_Next(Lst l)
|
||||
{
|
||||
register ListNode tln;
|
||||
register List list = (List)l;
|
||||
ListNode tln;
|
||||
List list = (List)l;
|
||||
|
||||
if ((LstValid (l) == FALSE) ||
|
||||
(list->isOpen == FALSE)) {
|
||||
@ -114,4 +113,3 @@ Lst_Next (l)
|
||||
|
||||
return ((LstNode)tln);
|
||||
}
|
||||
|
||||
|
@ -69,9 +69,9 @@ __FBSDID("$FreeBSD$");
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
ReturnStatus
|
||||
Lst_Open (l)
|
||||
register Lst l;
|
||||
Lst_Open(Lst l)
|
||||
{
|
||||
|
||||
if (LstValid (l) == FALSE) {
|
||||
return (FAILURE);
|
||||
}
|
||||
@ -81,4 +81,3 @@ Lst_Open (l)
|
||||
|
||||
return (SUCCESS);
|
||||
}
|
||||
|
||||
|
@ -64,12 +64,10 @@ __FBSDID("$FreeBSD$");
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
ReturnStatus
|
||||
Lst_Remove (l, ln)
|
||||
Lst l;
|
||||
LstNode ln;
|
||||
Lst_Remove(Lst l, LstNode ln)
|
||||
{
|
||||
register List list = (List) l;
|
||||
register ListNode lNode = (ListNode) ln;
|
||||
List list = (List) l;
|
||||
ListNode lNode = (ListNode) ln;
|
||||
|
||||
if (!LstValid (l) ||
|
||||
!LstNodeValid (ln, l)) {
|
||||
|
@ -62,10 +62,9 @@ __FBSDID("$FreeBSD$");
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
ReturnStatus
|
||||
Lst_Replace (ln, d)
|
||||
register LstNode ln;
|
||||
void * d;
|
||||
Lst_Replace(LstNode ln, void *d)
|
||||
{
|
||||
|
||||
if (ln == NULL) {
|
||||
return (FAILURE);
|
||||
} else {
|
||||
|
@ -64,13 +64,12 @@ __FBSDID("$FreeBSD$");
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
LstNode
|
||||
Lst_Succ (ln)
|
||||
LstNode ln;
|
||||
Lst_Succ(LstNode ln)
|
||||
{
|
||||
|
||||
if (ln == NULL) {
|
||||
return (NULL);
|
||||
} else {
|
||||
return ((LstNode) ((ListNode) ln)->nextPtr);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user