proof of concept planner

This commit is contained in:
simon committed 2024-12-12 16:08:19 +01:00
1 parent 6c91fb7d60
commit 7c16f20bc2
5 files changed
+149 -26

No files matched your search

+15 -1
View File
@@ -1,5 +1,7 @@
#include "llist.h"
#include <asm-generic/errno.h>
#include <stdlib.h>
#include <string.h>
/* create new linked list
* use llistFree after use
@@ -8,7 +10,7 @@
* only use to initialize
* To insert into list use llistAppend
*/
llist *llistNew(void *data, int (*cmpFN)(void *a, void *b)) {
llist *llistNew(void *data, int (*cmpFN)(const void *a, const void *b)) {
llist *r = (llist *)malloc(sizeof(llist));
if (r != NULL) {
r->cmpFn = cmpFN;
@@ -71,3 +73,15 @@ void llistFree(llist *head) {
head = tmp;
}
}
/*
* get linked list length
*/
int llistLen(llist *head) {
int len = 0;
llist *c = head;
while (c != NULL) {
len += 1;
c = c->next;
}
return len;
}