diff options
Diffstat (limited to 'src/util/mq.c')
-rw-r--r-- | src/util/mq.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/util/mq.c b/src/util/mq.c index b46e36ddf..fb679c18d 100644 --- a/src/util/mq.c +++ b/src/util/mq.c | |||
@@ -468,7 +468,28 @@ GNUNET_MQ_msg_ (struct GNUNET_MessageHeader **mhp, | |||
468 | 468 | ||
469 | 469 | ||
470 | /** | 470 | /** |
471 | * Implementation of the GNUNET_MQ_msg_nested_mh macro. | 471 | * Create a new envelope by copying an existing message. |
472 | * | ||
473 | * @param hdr header of the message to copy | ||
474 | * @return envelope containing @a hdr | ||
475 | */ | ||
476 | struct GNUNET_MQ_Envelope * | ||
477 | GNUNET_MQ_msg_copy (const struct GNUNET_MessageHeader *hdr) | ||
478 | { | ||
479 | struct GNUNET_MQ_Envelope *mqm; | ||
480 | uint16_t size = ntohs (hdr->size); | ||
481 | |||
482 | mqm = GNUNET_malloc (sizeof (*mqm) + size); | ||
483 | mqm->mh = (struct GNUNET_MessageHeader *) &mqm[1]; | ||
484 | memcpy (mqm->mh, | ||
485 | hdr, | ||
486 | size); | ||
487 | return mqm; | ||
488 | } | ||
489 | |||
490 | |||
491 | /** | ||
492 | * Implementation of the #GNUNET_MQ_msg_nested_mh macro. | ||
472 | * | 493 | * |
473 | * @param mhp pointer to the message header pointer that will be changed to allocate at | 494 | * @param mhp pointer to the message header pointer that will be changed to allocate at |
474 | * the newly allocated space for the message. | 495 | * the newly allocated space for the message. |