From: Christian Grothoff Date: Mon, 30 Jan 2017 16:42:00 +0000 (+0100) Subject: allow external code to use DLL pointers of envelopes, under very particular circumstances X-Git-Tag: taler-0.2.1~238 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=6c4af0398d260316dd2dd2358a02000cbf84ceba;p=oweals%2Fgnunet.git allow external code to use DLL pointers of envelopes, under very particular circumstances --- 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 */