From 2fa661c71bbfe37518bdefd7561aca475278b86a Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 25 Jun 2016 17:39:44 +0000 Subject: add GNUNET_MQ_send_copy --- src/util/mq.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/util/mq.c') diff --git a/src/util/mq.c b/src/util/mq.c index fb679c18d..b84db002a 100644 --- a/src/util/mq.c +++ b/src/util/mq.c @@ -309,6 +309,35 @@ GNUNET_MQ_send (struct GNUNET_MQ_Handle *mq, } +/** + * Send a copy of a message with the give message queue. + * Can be called repeatedly on the same envelope. + * + * @param mq message queue + * @param ev the envelope with the message to send. + */ +void +GNUNET_MQ_send_copy (struct GNUNET_MQ_Handle *mq, + const struct GNUNET_MQ_Envelope *ev) +{ + struct GNUNET_MQ_Envelope *env; + uint16_t msize; + + msize = ntohs (ev->mh->size); + env = GNUNET_malloc (sizeof (struct GNUNET_MQ_Envelope) + + msize); + env->mh = (struct GNUNET_MessageHeader *) &env[1]; + env->sent_cb = ev->sent_cb; + env->sent_cls = ev->sent_cls; + memcpy (&env[1], + ev->mh, + msize); + GNUNET_MQ_send (mq, + env); +} + + + /** * Task run to call the send implementation for the next queued * message, if any. Only useful for implementing message queues, -- cgit v1.2.3