wip: fork()

This commit is contained in:
0x35c
2025-11-12 15:07:36 +01:00
parent 02d196fab5
commit 34aa0f0eb4
9 changed files with 115 additions and 28 deletions

View File

@ -4,3 +4,6 @@ struct list {
void *content;
struct list *next;
};
struct list *lst_last(struct list *head);
void lst_add_back(struct list **head, struct list *e);

View File

@ -0,0 +1,10 @@
#include "list.h"
void lst_add_back(struct list **head, struct list *e)
{
struct list *last = lst_last(*head);
if (!last)
*head = e;
else
last->next = e;
}

View File

@ -0,0 +1,12 @@
#include "list.h"
#include <stddef.h>
struct list *lst_last(struct list *head)
{
if (!head)
return NULL;
struct list *it = head;
while (it->next)
it = it->next;
return it;
}