From 6c4af0398d260316dd2dd2358a02000cbf84ceba Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 30 Jan 2017 17:42:00 +0100 Subject: [PATCH] allow external code to use DLL pointers of envelopes, under very particular circumstances --- src/include/gnunet_mq_lib.h | 36 +++++++++++++++++++++++++++++ src/util/mq.c | 46 +++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) diff --git a/src/include/gnunet_mq_lib.h b/src/include/gnunet_mq_lib.h index 108ba5d54..b527b58e8 100644 --- a/src/include/gnunet_mq_lib.h +++ b/src/include/gnunet_mq_lib.h @@ -268,6 +268,42 @@ typedef void enum GNUNET_MQ_Error error); +/** + * Insert @a env into the envelope DLL starting at @a env_head + * Note that @a env must not be in any MQ while this function + * is used with DLLs defined outside of the MQ module. This + * is just in case some application needs to also manage a + * FIFO of envelopes independent of MQ itself and wants to + * re-use the pointers internal to @a env. Use with caution. + * + * @param[in|out] env_head of envelope DLL + * @param[in|out] env_tail tail of envelope DLL + * @param[in|out] env element to insert at the tail + */ +void +GNUNET_MQ_dll_insert_tail (struct GNUNET_MQ_Envelope **env_head, + struct GNUNET_MQ_Envelope **env_tail, + struct GNUNET_MQ_Envelope *env); + + +/** + * Remove @a env from the envelope DLL starting at @a env_head. + * Note that @a env must not be in any MQ while this function + * is used with DLLs defined outside of the MQ module. This + * is just in case some application needs to also manage a + * FIFO of envelopes independent of MQ itself and wants to + * re-use the pointers internal to @a env. Use with caution. + * + * @param[in|out] env_head of envelope DLL + * @param[in|out] env_tail tail of envelope DLL + * @param[in|out] env element to remove from the DLL + */ +void +GNUNET_MQ_dll_remove (struct GNUNET_MQ_Envelope **env_head, + struct GNUNET_MQ_Envelope **env_tail, + struct GNUNET_MQ_Envelope *env); + + /** * Message handler for a specific message type. */ diff --git a/src/util/mq.c b/src/util/mq.c index d12f69e5f..bd7ad7c47 100644 --- a/src/util/mq.c +++ b/src/util/mq.c @@ -1140,4 +1140,50 @@ GNUNET_MQ_destroy_notify_cancel (struct GNUNET_MQ_DestroyNotificationHandle *dnh } +/** + * Insert @a env into the envelope DLL starting at @a env_head + * Note that @a env must not be in any MQ while this function + * is used with DLLs defined outside of the MQ module. This + * is just in case some application needs to also manage a + * FIFO of envelopes independent of MQ itself and wants to + * re-use the pointers internal to @a env. Use with caution. + * + * @param[in|out] env_head of envelope DLL + * @param[in|out] env_tail tail of envelope DLL + * @param[in|out] env element to insert at the tail + */ +void +GNUNET_MQ_dll_insert_tail (struct GNUNET_MQ_Envelope **env_head, + struct GNUNET_MQ_Envelope **env_tail, + struct GNUNET_MQ_Envelope *env) +{ + GNUNET_CONTAINER_DLL_insert_tail (*env_head, + *env_tail, + env); +} + + +/** + * Remove @a env from the envelope DLL starting at @a env_head. + * Note that @a env must not be in any MQ while this function + * is used with DLLs defined outside of the MQ module. This + * is just in case some application needs to also manage a + * FIFO of envelopes independent of MQ itself and wants to + * re-use the pointers internal to @a env. Use with caution. + * + * @param[in|out] env_head of envelope DLL + * @param[in|out] env_tail tail of envelope DLL + * @param[in|out] env element to remove from the DLL + */ +void +GNUNET_MQ_dll_remove (struct GNUNET_MQ_Envelope **env_head, + struct GNUNET_MQ_Envelope **env_tail, + struct GNUNET_MQ_Envelope *env) +{ + GNUNET_CONTAINER_DLL_remove (*env_head, + *env_tail, + env); +} + + /* end of mq.c */ -- 2.25.1