sig_ll.h

include/sig/base/sig_ll.h

sig_dtor_fn

typedef void (*sig_dtor_fn)(void *value);

Identical shape to sig_ht's sig_dtor_fn (legal to redefine a typedef to the same type in C11) — sig_ll intentionally has no header dependency on sig_ht; they are independent peer collections.

sig_ll is NOT internally synchronized. The refcount (sig_ll_ref / sig_ll_destroy) only arbitrates which caller is responsible for tearing the list down when it's shared by pointer; it does not make concurrent sig_ll_push/pop/unshift/shift/remove/walk calls from multiple threads safe. A list touched from more than one thread must be protected by a mutex (e.g. sig_mutex from sig_thread.h) owned by the caller.

sig_ll_elem

typedef struct sig_ll_elem sig_ll_elem;

sig_ll_elem

struct sig_ll_elem {
    sig_ll_elem *prev;
    sig_ll_elem *next;
    void *value;
};

sig_ll

typedef struct {
    sig_refcount_h refcount;
    uint32_t num_elements;
    sig_ll_elem *head;
    sig_ll_elem *tail;
    sig_dtor_fn dtor;
} sig_ll;

sig_ll_create

sig_status_t sig_ll_create(sig_ll ** out_ll, sig_dtor_fn dtor)
ParameterType
out_llsig_ll **
dtorsig_dtor_fn

dtor may be NULL if stored values are not owned by the list. Applied on sig_ll_remove() and sig_ll_destroy(), never on pop()/shift() — those transfer ownership to the caller.

sig_ll_ref

void sig_ll_ref(sig_ll * ll)
ParameterType
llsig_ll *

Adds a reference to the list's refcount (sig_refcount_h). Each call to sig_ll_ref() must be matched by an additional call to sig_ll_destroy() before the list is actually freed.

sig_ll_destroy

void sig_ll_destroy(sig_ll * ll)
ParameterType
llsig_ll *

Releases a reference to the list. sig_ll_create() starts the refcount at 1, so a container that is never shared via sig_ll_ref() is fully torn down (elements destroyed via dtor, struct freed) on the first call, exactly as before. If other references remain, this call only decrements the count and returns without freeing or destroying anything.

sig_ll_push

sig_status_t sig_ll_push(sig_ll * ll, void * value)
ParameterType
llsig_ll *
valuevoid *

sig_ll_pop

sig_status_t sig_ll_pop(sig_ll * ll, void ** out_value)
ParameterType
llsig_ll *
out_valuevoid **

sig_ll_unshift

sig_status_t sig_ll_unshift(sig_ll * ll, void * value)
ParameterType
llsig_ll *
valuevoid *

sig_ll_shift

sig_status_t sig_ll_shift(sig_ll * ll, void ** out_value)
ParameterType
llsig_ll *
out_valuevoid **

sig_ll_remove

sig_status_t sig_ll_remove(sig_ll * ll, void * value)
ParameterType
llsig_ll *
valuevoid *

sig_ll_count

uint32_t sig_ll_count(const sig_ll * ll)
ParameterType
llconst sig_ll *

sig_ll_walk_fn

typedef sig_status_t (*sig_ll_walk_fn)(void *value, void *ctx);

sig_ll_walk

sig_status_t sig_ll_walk(sig_ll * ll, sig_ll_walk_fn func, void * ctx)
ParameterType
llsig_ll *
funcsig_ll_walk_fn
ctxvoid *