A simple api for working with linked lists.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example
.gitignore
LICENSE
README.md
llist.c
llist.h

README.md

LList

LList provides a quick way of using linked lists inside projects by providing a simple api. Since linked lists can be used several times inside a single project this allows for reducing redundant code.

Example

A simple Hello World like example using the api.
The example folder contains this as well as a Makefile to compile it.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "llist.h"

int
main (void)
{
	LList *list = NULL;
	
	// Append the first entry to the list
	list = llist_append (list, strdup ("Hello"));
	
	// Should print the word Hello
	LList *pos;
	
	LLIST_FOR_EACH (pos, list)
	{
		printf ("%.255s\n", (char*)pos->data);
	}
	
	// Make it a greeting to the World
	list = llist_append (list, strdup ("World!"));

	// Print all list entries in one line
	LLIST_FOR_EACH (pos, list)
	{
		printf ("%.255s%c",
		        (char*)pos->data,
		        (pos->next == NULL ? '\n' : ' '));
	}
	
	// Free the memory of all list entries
	llist_free_full (list, free);
	
	return 0;
}