RTI Connext DDS Micro  Version 2.4.10
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
osapi_heap_impl.h
Go to the documentation of this file.
1 /*
2  * FILE: osapi_heap_impl.h - Implementation of HEAP API
3  *
4  * (c) Copyright, Real-Time Innovations, 2008-2015
5  *
6  * All rights reserved.
7  *
8  * No duplications, whole or partial, manual or electronic, may be made
9  * without express written permission. Any such copies, or
10  * revisions thereof, must display this notice unaltered.
11  * This code contains trade secrets of Real-Time Innovations, Inc.
12  *
13  * Modification History
14  * --------------------
15  * 25feb2015,eh MICRO-356/PR#1496 Add OSAPI_Heap_allocate function for Cert
16  * 22sep2008,tk Created
17  */
18 /*ce \file
19  * \brief Macro implementing heap interface
20  */
21 #ifndef osapi_heap_impl_h
22 #define osapi_heap_impl_h
23 
24 #ifndef osapi_dll_h
25 #include "osapi/osapi_dll.h"
26 #endif
27 
28 #include "osapi/osapi_config.h"
29 
30 #ifdef HAVE_MALLOC_H
31 #include <malloc.h>
32 #else
33 #include <stdlib.h>
34 #endif
35 
36 /*--------------------------------------------------------------------------*/
37 /* This needs to stay a MACRO; not for performance reasons but because
38  it is the only way to pass a "type" into the "function"
39  */
40 #define OSAPI_Heap_allocate_struct(dest_, type_) \
41  *(dest_) = (type_ *)OSAPI_Heap_allocate(1, sizeof(type_))
42 /*--------------------------------------------------------------------------*/
43 #ifndef RTI_CERT
44 #define OSAPI_Heap_free_struct(dest_) \
45  if ((dest_) != NULL) OSAPI_Heap_free(dest_)
46 #else
47 #define OSAPI_Heap_free_struct(dest_)
48 #endif
49 /*--------------------------------------------------------------------------*/
50 /* This needs to stay a MACRO; not for performance reasons but because
51  it is the only way to pass a "type" into the "function"
52  */
53 #define OSAPI_Heap_allocate_array(dest_, count_, type_) \
54  *(dest_) = (type_ *)OSAPI_Heap_allocate(count_,sizeof(type_))
55 /*--------------------------------------------------------------------------*/
56 #ifndef RTI_CERT
57 #define OSAPI_Heap_free_array(dest_) \
58  if ((dest_) != NULL) OSAPI_Heap_free(dest_)
59 #else
60 #define OSAPI_Heap_free_array(dest_)
61 #endif
62 /*--------------------------------------------------------------------------*/
63 #define OSAPI_Heap_allocate_string(string_, size_) \
64  *(string_) = (char *)OSAPI_Heap_allocate((size_)+1, 1)
65 /*--------------------------------------------------------------------------*/
66 #ifndef RTI_CERT
67 #define OSAPI_Heap_free_string(string_) \
68  if ((string_) != NULL) OSAPI_Heap_free(string_)
69 #else
70 #define OSAPI_Heap_free_string(string_)
71 #endif
72 /*--------------------------------------------------------------------------*/
73 
74 #endif /* osapi_heap_impl_h */

RTI Connext DDS Micro Version 2.4.10 Copyright © Fri Jun 30 2017 Real-Time Innovations, Inc