LCOV - code coverage report
Current view: top level - core/src/mm - msg_allocator.h Hit Total Coverage
Test: ROOT-Sim develop Documentation Coverage Lines: 1 8 12.5 %
Date: 2021-03-02 11:24:52

          Line data    Source code
       1           1 : /**
       2             :  * @file mm/msg_allocator.h
       3             :  *
       4             :  * @brief Memory management functions for messages
       5             :  *
       6             :  * Memory management functions for messages
       7             :  *
       8             :  * SPDX-FileCopyrightText: 2008-2021 HPDCS Group <rootsim@googlegroups.com>
       9             :  * SPDX-License-Identifier: GPL-3.0-only
      10             :  */
      11             : #pragma once
      12             : 
      13             : #include <lp/msg.h>
      14             : 
      15             : #include <memory.h>
      16             : 
      17           0 : extern void msg_allocator_init(void);
      18           0 : extern void msg_allocator_fini(void);
      19             : 
      20           0 : extern struct lp_msg* msg_allocator_alloc(unsigned payload_size);
      21           0 : extern void msg_allocator_free          (struct lp_msg *msg);
      22           0 : extern void msg_allocator_free_at_gvt   (struct lp_msg *msg);
      23           0 : extern void msg_allocator_fossil_collect(simtime_t current_gvt);
      24             : 
      25           0 : inline struct lp_msg* msg_allocator_pack(lp_id_t receiver, simtime_t timestamp,
      26             :         unsigned event_type, const void *payload, unsigned payload_size)
      27             : {
      28             :         struct lp_msg *msg = msg_allocator_alloc(payload_size);
      29             : 
      30             :         msg->dest = receiver;
      31             :         msg->dest_t = timestamp;
      32             :         msg->m_type = event_type;
      33             :         msg->pl_size = payload_size;
      34             : 
      35             :         if(likely(payload_size))
      36             :                 memcpy(msg->pl, payload, payload_size);
      37             :         return msg;
      38             : }

Generated by: LCOV version 1.14