DriveWorks SDK Reference
3.5.78 Release
For Test and Development only

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