Newer
Older
tree-os / src / include / list.h
@lukas lukas on 9 Mar 2022 780 bytes add file system: fat 16
#ifndef LIST_H
#define LIST_H

#include <stdbool.h>
#include <stdint.h>

#define NULL (void *)0

#define foreach(list)                                                          \
    for (ListElement *current = list; current; current = current->next)

typedef struct ListElement {
    struct ListElement *next;
    void *data;
} ListElement;

extern void listAdd(ListElement **list, void *data);
extern void listAddSet(ListElement **list, void *data);
extern uint32_t listCount(ListElement *list);

extern void *popBeginning(ListElement **list);

extern void memset(void *buffer, uint8_t byte, uint32_t count);

extern void *listGet(ListElement **list, uint32_t index);
extern void *listPopEnd(ListElement **list);
extern void listClear(ListElement **list, bool freeData);

#endif