Next: , Previous: sll_join, Up: Singly Linked Lists


3.1.20 sll_new

Create a new singly linked list.

Synopsis

     #include <linklist/linklist.h>
     
     
     
SLinkList sll_new(int (*cmp)(const void *,const void *));

Parameters

int (*cmp)(const void *,const void *)
a comparison function for use in searches of the linked list, may be SLL_NULL_CMP for unordered lists

Description

This routine creates a new list structure. If the list is to have some intrinsic order, a function defining that order should be passed. The comparison routine is called with two node data pointers as the arguments. It must return ‘-1’, ‘0’, or ‘1’ if, respectively, the first argument is less than, equal to, or greater than the second.

Returns

It returns a pointer to a new linked list, or NULL if it can't allocate it