DriveWorks SDK Reference
5.4.5418 Release
For Test and Development only

DynamicMemory.h
Go to the documentation of this file.
1 //
3 // Notice
4 // ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
5 // NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
6 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
7 // MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8 //
9 // NVIDIA CORPORATION & AFFILIATES assumes no responsibility for the consequences of use of such
10 // information or for any infringement of patents or other rights of third parties that may
11 // result from its use. No license is granted by implication or otherwise under any patent
12 // or patent rights of NVIDIA CORPORATION & AFFILIATES. No third party distribution is allowed unless
13 // expressly authorized by NVIDIA. Details are subject to change without notice.
14 // This code supersedes and replaces all information previously supplied.
15 // NVIDIA CORPORATION & AFFILIATES products are not authorized for use as critical
16 // components in life support devices or systems without express written approval of
17 // NVIDIA CORPORATION & AFFILIATES.
18 //
19 // SPDX-FileCopyrightText: Copyright (c) 2016-2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
20 // SPDX-License-Identifier: LicenseRef-NvidiaProprietary
21 //
22 // NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
23 // property and proprietary rights in and to this material, related
24 // documentation and any modifications thereto. Any use, reproduction,
25 // disclosure or distribution of this material and related documentation
26 // without an express license agreement from NVIDIA CORPORATION or
27 // its affiliates is strictly prohibited.
28 //
30 
46 #ifndef DW_CORE_DYNAMIC_MEMORY_H_
47 #define DW_CORE_DYNAMIC_MEMORY_H_
48 
49 #include <stddef.h>
50 #include <stdbool.h>
51 
52 #ifdef DW_EXPORTS
53 #define DWALLOC_API_PUBLIC __attribute__((visibility("default")))
54 #else
55 #define DWALLOC_API_PUBLIC
56 #endif
57 
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61 
65 typedef enum dwDynamicMemoryError {
71 
72 typedef void* (*dwDynamicMemoryMallocCallback)(size_t sizeInByte, void* userData);
73 typedef void (*dwDynamicMemoryFreeCallback)(void* addr, void* userData);
74 typedef void (*dwDynamicMemoryErrorCallback)(dwDynamicMemoryError error, size_t lastRequestedSizeInByte, void* userData);
75 
89  dwDynamicMemoryFreeCallback freeCallback,
90  void* const userData);
91 
99 void dwDynamicMemory_setErrorCallback(dwDynamicMemoryErrorCallback errorCallback, void* const userData);
100 
111  dwDynamicMemoryFreeCallback* const freeCallback,
112  void** const userData);
113 
118 typedef enum dwRuntimeMode {
119  DW_MODE_INIT = 0x0000,
120  DW_MODE_RUNTIME = 0x0001,
121  DW_MODE_CLEANUP = 0x0002,
123 } dwRuntimeMode;
124 
137 
147 
154 
164 void* dwDynamicMemory_malloc(size_t const size);
165 
172 void dwDynamicMemory_free(void* const ptr);
173 
174 #ifdef __cplusplus
175 }
176 #endif
177 
178 #endif // DW_CORE_DYNAMIC_MEMORY_H_
DWALLOC_API_PUBLIC void dwDynamicMemory_initialize(dwDynamicMemoryMallocCallback mallocCallback, dwDynamicMemoryFreeCallback freeCallback, void *const userData)
Initialize dwDynamicMemory with user-defined callback for user space memory allocations.
dwRuntimeMode
Context runtime mode.
void(* dwDynamicMemoryFreeCallback)(void *addr, void *userData)
Definition: DynamicMemory.h:73
DWALLOC_API_PUBLIC void dwDynamicMemory_setErrorCallback(dwDynamicMemoryErrorCallback errorCallback, void *const userData)
Set error callback to be executed on an allocation error.
Heap memory allocations and deallocations are allowed.
DWALLOC_API_PUBLIC void dwDynamicMemory_getCallbacks(dwDynamicMemoryMallocCallback *const mallocCallback, dwDynamicMemoryFreeCallback *const freeCallback, void **const userData)
Get callbacks and user-defined general pointer previously passed in dwDynamicMemory_initialize.
Heap memory allocations and deallocations are allowed. Default.
Heap memory allocations are not allowed.
DWALLOC_API_PUBLIC void * dwDynamicMemory_malloc(size_t const size)
Allocate chunk of memory using allocator passed through dwDynamicMemory_initialize().
dwDynamicMemoryError
Error to be reported through error callback.
Definition: DynamicMemory.h:65
Allocation is currently not allowed, because in runtime mode.
Definition: DynamicMemory.h:68
void(* dwDynamicMemoryErrorCallback)(dwDynamicMemoryError error, size_t lastRequestedSizeInByte, void *userData)
Definition: DynamicMemory.h:74
Memory allocation failed, probably not enough memory.
Definition: DynamicMemory.h:67
DWALLOC_API_PUBLIC void dwDynamicMemory_release()
Release dwDynamicMemory.
DWALLOC_API_PUBLIC bool dwDynamicMemory_setRuntimeMode(dwRuntimeMode const newMode)
Switch runtime mode for all Driveworks SDK.
void *(* dwDynamicMemoryMallocCallback)(size_t sizeInByte, void *userData)
Definition: DynamicMemory.h:72
#define DWALLOC_API_PUBLIC
Definition: DynamicMemory.h:55
DWALLOC_API_PUBLIC bool dwDynamicMemory_getRuntimeMode(dwRuntimeMode *const mode)
Return currently selected runtime mode.
Memory release is currently not allowed, because in runtime mode.
Definition: DynamicMemory.h:69
DWALLOC_API_PUBLIC void dwDynamicMemory_free(void *const ptr)
Release memory chunk previously allocated with dwDynamicMemory_malloc().