]> git.ipfire.org Git - thirdparty/openssl.git/commit
list: add a doubly linked list type.
authorPauli <pauli@openssl.org>
Fri, 2 Sep 2022 04:44:02 +0000 (14:44 +1000)
committerPauli <pauli@openssl.org>
Mon, 5 Sep 2022 06:24:53 +0000 (16:24 +1000)
commitf5eac259a03c68c96c77f9b998b1b9c16a8439e7
tree99680e0106990591cf11130eb392ecea5de9165f
parent5ccee69b1384fa9377986a6f7730e0d9a372b42b
list: add a doubly linked list type.

These list can be embedded into structures and structures can be members of
multiple lists.  Moreover, this is done without dynamic memory allocation.
That is, this is legal:

    typedef struct item_st ITEM;

    struct item_st {
        ...
        OSSL_LIST_MEMBER(new_items, ITEM);
        OSSL_LIST_MEMBER(failed_items, ITEM);
        ...
    };

    DEFINE_LIST_OF(new_items, TESTL);
    DEFINE_LIST_OF(failed_items, TESTL);

    struct {
        ...
        OSSL_LIST(new_items) new;
        OSSL_LIST(failed_items) failed;
        ...
    } *st;

    ITEM *p;

    for (p = ossl_list_new_items_head(&st->new); p != NULL;
         p = ossl_list_new_items_next(p))
        /* do something */

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19115)
doc/internal/man3/DEFINE_LIST_OF.pod [new file with mode: 0644]
include/internal/list.h [new file with mode: 0644]
test/build.info
test/list_test.c [new file with mode: 0644]
test/recipes/02-test_list.t [new file with mode: 0644]