Sha256: 60a100091066b055450466b16f66a9aa38fc7bd31b716ee552faaa80e0990ae2

Contents?: true

Size: 841 Bytes

Versions: 5

Compression:

Stored size: 841 Bytes

Contents

#include "yarp/util/yp_list.h"

// Returns true if the given list is empty.
YP_EXPORTED_FUNCTION bool
yp_list_empty_p(yp_list_t *list) {
    return list->head == NULL;
}

// Returns the size of the list.
YP_EXPORTED_FUNCTION size_t
yp_list_size(yp_list_t *list) {
    return list->size;
}

// Append a node to the given list.
void
yp_list_append(yp_list_t *list, yp_list_node_t *node) {
    if (list->head == NULL) {
        list->head = node;
    } else {
        list->tail->next = node;
    }

    list->tail = node;
    list->size++;
}

// Deallocate the internal state of the given list.
YP_EXPORTED_FUNCTION void
yp_list_free(yp_list_t *list) {
    yp_list_node_t *node = list->head;
    yp_list_node_t *next;

    while (node != NULL) {
        next = node->next;
        free(node);
        node = next;
    }

    list->size = 0;
}

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
yarp-0.12.0 src/util/yp_list.c
yarp-0.11.0 src/util/yp_list.c
yarp-0.10.0 src/util/yp_list.c
yarp-0.9.0 src/util/yp_list.c
yarp-0.8.0 src/util/yp_list.c