diff options
| author | Alexandr Nedvedicky <[email protected]> | 2026-07-20 09:44:53 +0200 |
|---|---|---|
| committer | Norbert Pocs <[email protected]> | 2026-08-06 13:57:24 +0200 |
| commit | d7191d9d35ce320fc1e81c95200078f261d411ce (patch) | |
| tree | 2686f347c05ba33d97993b975a83a90e9fb48ab0 /include | |
| parent | Reject TLS 1.3 early data when PSK ciphersuite differs (diff) | |
| download | openssl-d7191d9d35ce320fc1e81c95200078f261d411ce.tar.gz openssl-d7191d9d35ce320fc1e81c95200078f261d411ce.zip | |
Add ossl_list_TYPE_join(head, tail) function
The function appends list tail to list head. List tail becomes
empty after the function returns.
Reviewed-by: Eugene Syromiatnikov <[email protected]>
Reviewed-by: Nikola Pajkovsky <[email protected]>
Reviewed-by: Norbert Pocs <[email protected]>
MergeDate: Thu Aug 6 11:57:39 2026
(Merged from https://github.com/openssl/openssl/pull/32031)
Diffstat (limited to 'include')
| -rw-r--r-- | include/internal/list.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/include/internal/list.h b/include/internal/list.h index 8bb0b741bed..cd43471409f 100644 --- a/include/internal/list.h +++ b/include/internal/list.h @@ -194,6 +194,35 @@ list->omega = elem; \ list->num_elems++; \ } \ + static ossl_unused ossl_inline void \ + ossl_list_##name##_join(OSSL_LIST(name) * lh, OSSL_LIST(name) * lt) \ + { \ + OSSL_LIST_DBG(type * _p); /* local variable '_p' when debug */ \ + if (lt == NULL || lh == NULL || lt->num_elems == 0 || lh == lt) \ + return; \ + /* \ + * let's be optimistic about size_t overflow here: it can not happen. \ + */ \ + lh->num_elems += lt->num_elems; \ + if (lh->omega == NULL) { \ + assert(lh->alpha == NULL); \ + lh->omega = lt->omega; \ + lh->alpha = lt->alpha; \ + } else { \ + if (lt->alpha != NULL) \ + ((type *)lt->alpha)->ossl_list_##name.prev = lh->omega; \ + ((type *)lh->omega)->ossl_list_##name.next = lt->alpha; \ + } \ + OSSL_LIST_DBG(for (_p = (type *)lt->alpha; \ + assert(_p == NULL || _p->ossl_list_##name.list == lt), _p != NULL; \ + _p = _p->ossl_list_##name.next) \ + _p->ossl_list_##name.list \ + = lh); \ + lh->omega = lt->omega; \ + lt->alpha = NULL; \ + lt->omega = NULL; \ + lt->num_elems = 0; \ + } \ struct ossl_list_st_##name #define DEFINE_LIST_OF(name, type) \ |
