Skip to content

ListAt

ListAt

Description

Data in node at given index in given list This is a more expensive call. Fetches pointer to data twice and then dereferences. Better use ListPtrAt instead.

Parameters

Name Direction Description
l in List to get data from.
idx in Index to get data at.

Success

Data from node in list at given index.

Failure

Emtpy object.

Usage example (Cross-references)

Usage examples (Cross-references)
                uint16_t idx = extract_u16(data, offset, size);
                if (idx < list->length) {
                    volatile i32 value = ListAt(list, idx);
                    (void)value; // Prevent optimization
                }
    
    #ifdef __cplusplus
    #    define ListAt(l, idx) (ListPtrAt((l), (idx)) ? *ListPtrAt((l), (idx)) : (LIST_DATA_TYPE(l) {0}))
    #else
    ///
    /// FAILURE: Emtpy object.
    ///
    #define ListFirst(l) ListAt((l), 0)
    
    ///
    /// FAILURE: Emtpy object.
    ///
    #define ListLast(l) ListAt((l), (l)->length - 1)
    
    ///
Last updated on