63 lines
940 B
C
63 lines
940 B
C
|
|
#include <debug.h>
|
|
|
|
#include "struct.h"
|
|
#include "append.h"
|
|
|
|
void linked_list_append(
|
|
struct linked_list* this,
|
|
struct value* value,
|
|
size_t offset)
|
|
{
|
|
ENTER;
|
|
|
|
if (this->tail)
|
|
{
|
|
struct value* tail = this->tail;
|
|
|
|
struct link* tail_link = (void*) tail + offset;
|
|
|
|
tail_link->next = value;
|
|
|
|
struct link* value_link = (void*) value + offset;
|
|
|
|
assert(value_link->in_set == false);
|
|
|
|
value_link->in_set = true;
|
|
|
|
value_link->prev = tail;
|
|
value_link->next = NULL;
|
|
|
|
this->tail = value;
|
|
}
|
|
else
|
|
{
|
|
this->tail = this->head = value;
|
|
|
|
struct link* link = (void*) value + offset;
|
|
|
|
assert(link->in_set == false);
|
|
|
|
link->in_set = true;
|
|
|
|
link->prev = NULL;
|
|
link->next = NULL;
|
|
}
|
|
|
|
EXIT;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|