libmicrohttpd2

HTTP server C library (MHD 2.x, alpha)
Log | Files | Refs | README | LICENSE

commit d08a352c08e3b4e9bb2743587dd3a2631e578f87
parent 154ddea53eea661b1ef2192a525aec46cbd366d6
Author: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
Date:   Sun, 21 Dec 2025 11:08:25 +0100

mhd_dlinked_list.h: added new macro-operators

Diffstat:
Msrc/mhd2/mhd_dlinked_list.h | 37++++++++++++++++++++++++++++++++++++-
1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/src/mhd2/mhd_dlinked_list.h b/src/mhd2/mhd_dlinked_list.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later OR (GPL-2.0-or-later WITH eCos-exception-2.0) */ /* This file is part of GNU libmicrohttpd. - Copyright (C) 2024 Evgeny Grin (Karlson2k) + Copyright (C) 2024-2025 Evgeny Grin (Karlson2k) GNU libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -53,6 +53,7 @@ #include "sys_null_macro.h" #include "mhd_assert.h" +#include "mhd_assume.h" /* This header defines macros for handling doubly-linked lists of objects. @@ -244,6 +245,40 @@ */ #define mhd_DLINKEDL_GET_LAST_D(p_list) ((p_list)->last) +/** + * Move the object within the list to the first position using a direct pointer + * to the list + * @warning arguments are evaluated multiple times + * @param p_list the pointer to the list + * @param p_obj the pointer to the existing list member object to move to the + * first position + * @param links_name the name of the links member in the @a p_obj + */ +#define mhd_DLINKEDL_MOVE_TO_FIRST_D(p_list,p_obj,links_name) do { \ + mhd_ASSUME (NULL != (p_list)->first); \ + mhd_ASSUME (NULL != (p_list)->last); \ + mhd_ASSUME ((p_obj) != (p_obj)->links_name.next); \ + mhd_ASSUME ((p_obj) != (p_obj)->links_name.prev); \ + if (NULL == (p_obj)->links_name.prev) \ + { mhd_ASSUME ((p_obj) == (p_list)->first); } else \ + { mhd_ASSUME ((p_obj) != (p_list)->first); \ + mhd_ASSUME ((p_obj) == \ + (p_obj)->links_name.prev->links_name.next); \ + (p_obj)->links_name.prev->links_name.next = \ + (p_obj)->links_name.next; \ + if (NULL == (p_obj)->links_name.next) \ + { mhd_ASSUME ((p_obj) == (p_list)->last); \ + (p_list)->last = (p_obj)->links_name.prev; } else \ + { mhd_ASSUME ((p_obj) != (p_list)->last); \ + mhd_ASSUME ((p_obj) == \ + (p_obj)->links_name.next->links_name.prev); \ + (p_obj)->links_name.next->links_name.prev = \ + (p_obj)->links_name.prev; } \ + (p_obj)->links_name.next = (p_list)->first; \ + (p_obj)->links_name.prev = NULL; \ + (p_list)->first->links_name.prev = (p_obj); \ + (p_list)->first = (p_obj); } } while (0) + /* ** The main interface ** */ /* These macros use identical names for the list object itself (within the