Skip to content
ListPushFrontL

ListPushFrontL

Description

Prepend an element at the head of the list. L-value ownership form.

Success

Returns true. A new node holding lval’s payload is linked as the new head; the list length grows by one. When the list has no copy_init handler, lval has been zeroed.

Failure

Returns false on allocation failure. The list and lval are unchanged.

Usage example (Cross-references)

Usage examples (Cross-references)
        ListInsertR(&list, b, 1);
        ListInsert(&list, c, 1);
        ListPushFrontL(&list, d);
        ListPushFrontR(&list, h);
        ListPushBackR(&list, e);
    /// TAGS: List, PushFront, Insert
    ///
    #define ListPushFront(l, lval) ListPushFrontL((l), (lval))
    
    ///
    #define ListMustPushFrontL(l, lval)                                                                                    \
        do {                                                                                                               \
            if (!ListPushFrontL((l), (lval))) {                                                                            \
                LOG_FATAL("ListMustPushFrontL failed");                                                                    \
            }                                                                                                              \
Last updated on