initial commit

This commit is contained in:
2026-03-12 13:22:29 +05:30
commit 44e461b5f6
2 changed files with 246 additions and 0 deletions

34
llist.h Normal file
View 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__ */