/* * Simple implementation of unsorted linked list of integers. */ #include #ifndef LIST_H_ #define LIST_H_ 1 /* Data structure for list node. */ typedef struct int_list_node { int data; struct int_list_node * next; } int_list_node_t; /* Data structure for list. */ typedef struct int_list { int_list_node_t * head; } int_list_t; /* * Creates list. * Returns NULL on error. */ int_list_t * int_list_create(void); /* * Free list (and all its elements). */ void int_list_free(int_list_t * t); /* * Insert element into list. * Returns -1 on error. */ int int_list_insert(int_list_t * l, int elem); /* * Remove selected element everywhere it occurs. * Returns -1 if element is not found. */ int int_list_remove(int_list_t * l, int elem); /* * Print all elements of list, one per line. Parameter "fmt" is * a format string suitable for passing to fprintf. */ void int_list_print(FILE * outstream, const char * fmt, int_list_t * l); #endif /* LIST_H_ */