| iMatix home page | << | < | > | >> |
SFL Version 2.11 |
#include "sflnode.h" void * node_create ( void *after, size_t size)
Creates a new node with the specified size, and attaches it to the linked list after the specified node. Initialises all fields in the node (except the main list pointers) to binary zeroes. If the 'after' argument is null, initialises but does not attach the node. Returns a pointer to the newly-created node, or NULL if there was not enough memory.
typedef struct { void *prev, *next; long data; } BLOCK; NODE head; BLOCK *pointer; // Initialise head of list node_reset (&head); // Attach new block to start of list pointer = (BLOCK *) node_create (&head, sizeof (BLOCK)); pointer-> data = 1; // Attach new block to end of list pointer = (BLOCK *) node_create (head.prev, sizeof (BLOCK)); pointer-> data = 1000;
{ NODE *node; /* Allocated node */ ASSERT (size > 0); if ((node = mem_alloc (size)) != NULL) { memset (node, 0, size); node_reset (node); /* Initialise node pointers */ if (after) /* Link into list if required */ node relink after (node, after); } return (node); }
| << | < | > | >> | Copyright © 1996-2000 iMatix Corporation |