Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'pikachuyann/simgrid-stoprofiles'
[simgrid.git] / examples / c / dht-kademlia / message.c
1 /* Copyright (c) 2012-2020. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include "message.h"
8 #include "answer.h"
9
10 kademlia_message_t new_message(unsigned int sender_id, unsigned int destination_id, answer_t answer,
11                                sg_mailbox_t mailbox, const char* hostname)
12 {
13   kademlia_message_t msg = xbt_new(s_kademlia_message_t, 1);
14
15   msg->sender_id        = sender_id;
16   msg->destination_id   = destination_id;
17   msg->answer           = answer;
18   msg->answer_to        = mailbox;
19   msg->issuer_host_name = hostname;
20
21   return msg;
22 }
23
24 void free_message(void* message)
25 {
26   const kademlia_message_t msg = (kademlia_message_t)message;
27   if (msg)
28     answer_free(msg->answer);
29   free(msg);
30 }