---
name: "wnsll"
section: "3"
platform: "linux"
package: "libwn-dev"
version: "6.0-17"
release: "Debian 4.0 (Etch)"
platforms: ["linux"]
url: "https://new.carta.tech/wnsll"
---

# wnsll(3)

singly linked list manager

## NAME

wn\_sllget\_index, wn\_sllrev, wn\_sllcpy, wn\_sllcat, wn\_sllins\_sll, wn\_sllend, wn\_slllast, wn\_sllempty, wn\_sllcount, wn\_mksll, wn\_freesll, wn\_freesll\_list, wn\_sllins, wn\_slleins, wn\_slldel, wn\_slledel, wn\_slleunlink, wn\_sllindex, wn\_slleindex - singly linked list manager

## SYNOPSIS

```
#include <wn/wnsll.h>

wn_sll el;
el->contents;
el->next;

wn_mksll(&ll)
wn_sll ll;

wn_freesll(ll);
wn_sll ll;

wn_freesll_list(ll);
wn_sll ll;

wn_sllins(&list, e)
wn_sll list;
ptr e;

wn_slleins(&list, el)
wn_sll list, el;

wn_slldel(&list, e)
wn_sll list;
ptr e;

wn_slledel(pel)
wn_sll *pel;

wn_slleunlink(pel)
wn_sll *pel;

wn_sllindex(&contents, list, index)
ptr contents;
wn_sll list;
int index;

wn_slleindex(&el, list, index)
wn_sll el, list;
int index;

wn_sllget_index(&index, list, e)
int index;
wn_sll list;
ptr e;

wn_sllrev(&list)
wn_sll list;

wn_sllcpy(&out, in)
wn_sll out, in;

wn_sllcat(&out, in)
wn_sll out, in;

wn_sllins_sll(&out, in)
wn_sll out, in;

wn_sllend(&pend, &list)
wn_sll *pend, list;

wn_slllast(&last, list)
wn_sll last, list;

bool wn_sllempty(list)
wn_sll list;

int wn_sllcount(list)
wn_sll list;
```

## DESCRIPTION

This package defines a singly linked list type called "wn\_sll".  Routines and macros operate on lists and elements of lists.

The declaration

wn\_sll *ll*;

declares a list element, which is also a list.  The fragment

*ll*-\>next

refers to the next linked list element.  The fragment

*ll*-\>contents

is a pointer associated with the linked list element.

**wn\_mksll** allocates a **wn\_sll** from the current memory group. *ll*-\>next and *ll*-\>contents are **NULL**.

**wn\_sllins** inserts *e* into list *list* by allocating a list element (from the current memory group), setting its contents to *e*, and chaining it to the front of *list*.

**wn\_slleins** chains *el* to the front of *list*.

**wn\_slldel** searches *list* until it finds a list element with contents == *e*.  This element is deleted from the list and freed into the current memory group.

**wn\_slledel** deletes the list element \**pel* from its containing *list* by setting "\**pel* = (\**pel*)-\>next;".  Then the list element is freed into the current memory group.

**wn\_slleunlink** deletes the list element \**pel* from its containing list by setting "\**pel* = (\**pel*)-\>next;".

**wn\_sllindex** places the contents of the \\fIindex\\fPth element of *list* into *contents*.  Unreasonable values of *index* are NOT  trapped.

**wn\_slleindex** places the \\fIindex\\fPth element of *list* into *el*.  Unreasonable values of *index* are NOT  trapped.

**wn\_sllrev** reverses the order of *list*.  Useful because **wn\_sllins** leaves the list reversed from the order of insertion.

**wn\_sllcpy** places a memory-allocated copy of *in* into *out*. The memory is allocated from the current memory group.

**wn\_sllcat** concatonates *in* to the end of *out*, preserving the order of both.  No new memory is allocated.

**wn\_sllins\_sll** chains the list *in* to the front of *out*.

**wn\_sllend** places the *last*-\>next pointer of *list* into *pend*.

**wn\_slllast** gets the last element of *list*.

**wn\_sllempty** returns TRUE iff *list* is empty.

**wn\_sllcount** returns the number of entries in list.

## SEE ALSO

wnhtab

## AUTHOR

Will Naylor
