ValidateList

Table of Contents

ValidateList

Description

Validate whether a given List object is valid. Not foolproof but will work most of the time. Aborts if provided List is not valid.

Parameters

NameDirectionDescription
linPointer to List object to validate.

Success

Continue execution, meaning given List object is most probably a valid List.

Failure

abort with an error message.

Usage example (Cross-references)

    }
    
    ValidateList(list);
    
    clear_list(list, item_size);
    }
    
    ValidateList(list);
    
    GenericListNode *new_node = calloc(sizeof(GenericListNode), 1);
    }
    
    ValidateList(list);
    
    if (count == 0) {
    }
    
    ValidateList(list);
    
    void *data       = malloc(item_size * list->length);
    }
    
    ValidateList(list);
    
    GenericListNode *n1 = node_at_list(list, item_size, idx1);
    }
    
    ValidateList(list);
    
    u64 i = list->length / 2;
    }
    
    ValidateList(list);
    
    while (count--) {
    }
    
    ValidateList(list1);
    ValidateList(list2);
    
    ValidateList(list1);
    ValidateList(list2);
    
    GenericListNode *node = list2->head;
    }
    
    ValidateList(list);
    
    remove_range_list(list, NULL, item_size, 0, list->length);
    }
    
    ValidateList(list);
    
    if (idx >= list->length) {
    }
    
    ValidateList(list);
    
    if (idx >= list->length) {
    }
    
    ValidateList(list);
    
    u64 abs_target_idx = nidx + ridx;
    #define ListInsertL(l, lval, idx)                                                                                      \
    do {                                                                                                               \
    ValidateList(l);                                                                                               \
    LIST_DATA_TYPE(l) * UNPL(_ptrval) = &(lval);                                                                   \
    LIST_DATA_TYPE(l) UNPL(_tmpval)   = *UNPL(_ptrval);                                                            \
    #define ListInsertR(l, rval, idx)                                                                                      \
    do {                                                                                                               \
    ValidateList(l);                                                                                               \
    LIST_DATA_TYPE(l) UNPL(_rval) = (rval);                                                                        \
    insert_into_list(GENERIC_LIST(l), (char *)&UNPL(_rval), sizeof(LIST_DATA_TYPE(l)), (idx));                     \
    #define ListPushArrL(l, arr, count)                                                                                    \
    do {                                                                                                               \
    ValidateList(l);                                                                                               \
    LIST_DATA_TYPE(l) * UNPL(_ptrval)     = (arr);                                                                 \
    const LIST_DATA_TYPE(l) UNPL(_tmpval) = *UNPL(_ptrval);                                                        \
    #define ListMergeL(l, l2)                                                                                              \
    do {                                                                                                               \
    ValidateList(l);                                                                                               \
    ValidateList(l2);                                                                                              \
    {                                                                                                              \
    do {                                                                                                               \
    ValidateList(l);                                                                                               \
    ValidateList(l2);                                                                                              \
    {                                                                                                              \
    LIST_DATA_TYPE(l) UNPL(_tmp1)  = {0};                                                                      \
    #define ListMergeR(l, l2)                                                                                              \
    do {                                                                                                               \
    ValidateList(l);                                                                                               \
    ValidateList(l2);                                                                                              \
    {                                                                                                              \
    do {                                                                                                               \
    ValidateList(l);                                                                                               \
    ValidateList(l2);                                                                                              \
    {                                                                                                              \
    LIST_DATA_TYPE(l) UNPL(_tmp1)  = {0};                                                                      \
    #define ListForeach(l, var)                                                                                                      \
    for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                                   \
    if ((ValidateList(UNPL(pl)), 1) && (UNPL(pl)->head))                                                                     \
    for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)); UNPL(node);                          \
    UNPL(node)                   = ListNodeNext(UNPL(node)))                                                        \
    #define ListForeachPtr(l, var)                                                                                                 \
    for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                                 \
    if ((ValidateList(UNPL(pl)), 1) && (UNPL(pl)->head))                                                                   \
    for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)); UNPL(node);                        \
    UNPL(node)                   = ListNodeNext(UNPL(node)))                                                      \
    #define ListForeachReverse(l, var)                                                                                               \
    for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                                   \
    if ((ValidateList(UNPL(pl)), 1) && (UNPL(pl)->tail))                                                                     \
    for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeEnd(UNPL(pl)); UNPL(node);                            \
    UNPL(node)                   = ListNodePrev(UNPL(node)))                                                        \
    #define ListForeachPtrReverse(l, var)                                                                                          \
    for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                                 \
    if ((ValidateList(UNPL(pl)), 1) && (UNPL(pl)->tail))                                                                   \
    for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeEnd(UNPL(pl)); UNPL(node);                          \
    UNPL(node)                   = ListNodePrev(UNPL(node)))                                                      \
    #define ListForeachInRange(l, var, start, end)                                                                                           \
    for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                                           \
    if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->head)                                                                               \
    for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)); UNPL(node);                                  \
    UNPL(node)                   = ListNodeNext(UNPL(node)))                                                                \
    #define ListForeachPtrInRange(l, var, start, end)                                                                                        \
    for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                                           \
    if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->head)                                                                               \
    for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)); UNPL(node);                                  \
    UNPL(node)                   = ListNodeNext(UNPL(node)))                                                                \
    #define ListForeachReverseInRange(l, var, start, end)                                                                                    \
    for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                                           \
    if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->tail)                                                                               \
    for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeEnd(UNPL(pl)); UNPL(node);                                    \
    UNPL(node)                   = ListNodePrev(UNPL(node)))                                                                \
    #define ListForeachPtrReverseInRange(l, var, start, end)                                                                                 \
    for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                                           \
    if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->tail)                                                                               \
    for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeEnd(UNPL(pl)); UNPL(node);                                    \
    UNPL(node)                   = ListNodePrev(UNPL(node)))                                                                \
    #define ListForeachIdx(l, var, idx)                                                                                    \
    for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                         \
    if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->head)                                                             \
    for (u64 idx = 0, UNPL(pidx) = 0; idx < UNPL(pl)->length;)                                                 \
    for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)), *UNPL(next) = NULL;    \
    #define ListForeachPtrIdx(l, var, idx)                                                                                 \
    for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                         \
    if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->head)                                                             \
    for (u64 idx = 0, UNPL(pidx) = 0; idx < UNPL(pl)->length;)                                                 \
    for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)), *UNPL(next) = NULL;    \
    #define ListForeachReverseIdx(l, var, idx)                                                                             \
    for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                         \
    if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->tail && UNPL(pl)->length > 0)                                     \
    for (u64 idx            = UNPL(pl)->length - 1,                                                            \
    UNPL(pidx)     = UNPL(pl)->length - 1,                                                            \
    #define ListForeachPtrReverseIdx(l, var, idx)                                                                          \
    for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                         \
    if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->tail && UNPL(pl)->length > 0)                                     \
    for (u64 idx            = UNPL(pl)->length - 1,                                                            \
    UNPL(pidx)     = UNPL(pl)->length - 1,                                                            \

Share :