initial commit
This commit is contained in:
34
llist.h
Normal file
34
llist.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* llist.h
|
||||
* Generic linked list implementation in C
|
||||
*/
|
||||
#ifndef __LLIST_H__
|
||||
#define __LLIST_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define container_of(ptr, type, member) ({ \
|
||||
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
|
||||
(type *)((char *)__mptr - offsetof(type,member));})
|
||||
|
||||
|
||||
typedef struct ListNode{
|
||||
void *data;
|
||||
struct ListNode *next;
|
||||
} ListNode;
|
||||
|
||||
typedef ListNode * List;
|
||||
|
||||
List *create_list(void *data);
|
||||
|
||||
uint32_t list_size(List *list);
|
||||
|
||||
List *list_add(List *list, void *data, uint32_t position);
|
||||
|
||||
List *list_remove(List *list, uint32_t position);
|
||||
|
||||
void list_delete(List *list);
|
||||
|
||||
#endif /* __LLIST_H__ */
|
||||
Reference in New Issue
Block a user