wip: fork()
This commit is contained in:
@ -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);
|
||||
|
||||
10
libbozo/src/list/lst_add_back.c
Normal file
10
libbozo/src/list/lst_add_back.c
Normal 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;
|
||||
}
|
||||
12
libbozo/src/list/lst_last.c
Normal file
12
libbozo/src/list/lst_last.c
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user