rcl  beta1
C API providing common ROS client library functionality.
allocator.h
Go to the documentation of this file.
1 // Copyright 2015 Open Source Robotics Foundation, Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef RCL__ALLOCATOR_H_
16 #define RCL__ALLOCATOR_H_
17 
18 #if __cplusplus
19 extern "C"
20 {
21 #endif
22 
23 #include "rcl/macros.h"
24 #include "rcl/types.h"
25 #include "rcl/visibility_control.h"
26 
28 
40 typedef struct rcl_allocator_t
41 {
43 
44  void * (*allocate)(size_t size, void * state);
46 
47  void (* deallocate)(void * pointer, void * state);
49 
59  void * (*reallocate)(void * pointer, size_t size, void * state);
61 
62  void * state;
64 
66 
86 
88 
94 void *
95 rcl_reallocf(void * pointer, size_t size, rcl_allocator_t * allocator);
96 
97 #if __cplusplus
98 }
99 #endif
100 
101 #endif // RCL__ALLOCATOR_H_
rcl_allocator_t rcl_get_default_allocator(void)
Return a properly initialized rcl_allocator_t with default values.
void * state
Implementation defined state storage.
Definition: allocator.h:62
#define RCL_WARN_UNUSED
Ignored return values of functions with this macro will emit a warning.
Definition: macros.h:25
#define RCL_PUBLIC
Definition: visibility_control.h:48
void(* deallocate)(void *pointer, void *state)
Deallocate previously allocated memory, mimicking std::free().
Definition: allocator.h:47
Encapsulation of an allocator.
Definition: allocator.h:40
void * rcl_reallocf(void *pointer, size_t size, rcl_allocator_t *allocator)
Emulate the behavior of reallocf.
struct rcl_allocator_t rcl_allocator_t
Encapsulation of an allocator.