Skip to content

horta/cugar

Repository files navigation

cugar library

C99 compliant.

Functions

void         list_init(struct list* list);
struct list* list_head(struct list const* list);
struct list* list_tail(struct list const* list);
struct list* list_next(struct list const* list, struct list* item);
void         list_ins(struct list* where, struct list* item);
void         list_add(struct list* list, struct list* item);
void         list_del(struct list* item);

Usage

#include "list.h"

struct Foo
{
    int         value;
    struct list link;
};

int main(void)
{
    struct list list;
    list_init(&list);

    struct Foo foo = {.value = 0};

    list_add(&list, &foo.link);

    return CONTAINER_OF(list_head(&list), struct Foo, link)->value;
}

Check

cc list_example.c -Wall -pedantic -std=c99 -o ./list_example

About

Sugar for your C standard library.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published