NVIDIA DriveOS Linux SDK API Reference

7.2.5.0 Early Access Release
DynamicMemory.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2016-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: LicenseRef-NvidiaProprietary
4  *
5  * NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
6  * property and proprietary rights in and to this material, related
7  * documentation and any modifications thereto. Any use, reproduction,
8  * disclosure or distribution of this material and related documentation
9  * without an express license agreement from NVIDIA CORPORATION or
10  * its affiliates is strictly prohibited.
11  */
12 
29 #ifndef DW_CORE_DYNAMIC_MEMORY_H_
30 #define DW_CORE_DYNAMIC_MEMORY_H_
31 
32 #include <stddef.h>
33 #include <stdbool.h>
34 
35 // clang-format off
36 
37 // DWALLOC_PRAGMA_COVERITY
38 //
39 // We can't use DW_PRAGMA_COVERITY because this library does not depend on
40 // //src/dwshared/dwfoundation/dw/core/platform:dwfoundation_core_platform.
41 //
42 #ifdef __COVERITY__
43  #define DWALLOC_PRAGMA_COVERITY(s) _Pragma(s)
44 #else
45  #define DWALLOC_PRAGMA_COVERITY(s)
46 #endif
47 
48 // DWALLOC_API_PUBLIC
49 #if __GNUC__ >= 4
50  // Use GNU C extension supported by GCC [1][2] and Clang [3].
51  //
52  // [1] https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
53  // [2] https://gcc.gnu.org/wiki/Visibility
54  // [3] https://clang.llvm.org/docs/AttributeReference.html#visibility
55  //
56  #define DWALLOC_API_PUBLIC \
57  DWALLOC_PRAGMA_COVERITY("coverity compliance deviate autosar_cpp14_a1_1_1 'RFD Accepted: TID-3086'") \
58  __attribute__ ((visibility("default")))
59 #else
60  #define DWALLOC_API_PUBLIC
61 #endif
62 
63 // clang-format on
64 
65 #ifdef __cplusplus
66 extern "C" {
67 #endif
68 
72 typedef enum {
78 
79 typedef void* (*dwDynamicMemoryMallocCallback)(size_t sizeInByte, void* userData);
80 typedef void (*dwDynamicMemoryFreeCallback)(void* addr, void* userData);
81 typedef void (*dwDynamicMemoryErrorCallback)(dwDynamicMemoryError error, size_t lastRequestedSizeInByte, void* userData);
82 
107  dwDynamicMemoryFreeCallback freeCallback,
108  void* const userData);
109 
129 void dwDynamicMemory_setErrorCallback(dwDynamicMemoryErrorCallback errorCallback, void* const userData);
130 
151  dwDynamicMemoryFreeCallback* const freeCallback,
152  void** const userData);
153 
158 typedef enum {
159  DW_MODE_INIT = 0x0000,
160  DW_MODE_RUNTIME = 0x0001,
161  DW_MODE_CLEANUP = 0x0002,
163 } dwRuntimeMode;
164 
190 
210 
229 void dwDynamicMemory_release(void);
230 
252 void* dwDynamicMemory_malloc(size_t const size);
253 
274 void dwDynamicMemory_free(void* const ptr);
275 
276 #ifdef __cplusplus
277 }
278 #endif
279 
280 #endif // DW_CORE_DYNAMIC_MEMORY_H_
281 
dwDynamicMemoryError
dwDynamicMemoryError
Error to be reported through error callback.
Definition: DynamicMemory.h:72
dwDynamicMemory_free
DWALLOC_API_PUBLIC void dwDynamicMemory_free(void *const ptr)
Release memory chunk previously allocated with dwDynamicMemory_malloc().
dwDynamicMemory_getRuntimeMode
DWALLOC_API_PUBLIC bool dwDynamicMemory_getRuntimeMode(dwRuntimeMode *const mode)
Return currently selected runtime mode.
dwDynamicMemoryFreeCallback
void(* dwDynamicMemoryFreeCallback)(void *addr, void *userData)
Definition: DynamicMemory.h:80
DW_DYNAMIC_MEMORY_SUCCESS
@ DW_DYNAMIC_MEMORY_SUCCESS
no error
Definition: DynamicMemory.h:73
dwDynamicMemoryMallocCallback
void *(* dwDynamicMemoryMallocCallback)(size_t sizeInByte, void *userData)
Definition: DynamicMemory.h:79
dwRuntimeMode
dwRuntimeMode
Context runtime mode.
Definition: DynamicMemory.h:158
DW_MODE_CLEANUP
@ DW_MODE_CLEANUP
Heap memory allocations and deallocations are allowed.
Definition: DynamicMemory.h:161
dwDynamicMemory_getCallbacks
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.
DW_MODE_INIT
@ DW_MODE_INIT
Heap memory allocations and deallocations are allowed. Default.
Definition: DynamicMemory.h:159
dwDynamicMemory_setRuntimeMode
DWALLOC_API_PUBLIC bool dwDynamicMemory_setRuntimeMode(dwRuntimeMode const newMode)
Switch runtime mode for all Driveworks SDK.
dwDynamicMemoryErrorCallback
void(* dwDynamicMemoryErrorCallback)(dwDynamicMemoryError error, size_t lastRequestedSizeInByte, void *userData)
Definition: DynamicMemory.h:81
DW_DYNAMIC_MEMORY_FREE_NOT_ALLOWED
@ DW_DYNAMIC_MEMORY_FREE_NOT_ALLOWED
Memory release is currently not allowed, because in runtime mode.
Definition: DynamicMemory.h:76
DW_DYNAMIC_MEMORY_BAD_ALLOC
@ DW_DYNAMIC_MEMORY_BAD_ALLOC
Memory allocation failed, probably not enough memory.
Definition: DynamicMemory.h:74
DW_MODE_COUNT
@ DW_MODE_COUNT
Definition: DynamicMemory.h:162
dwDynamicMemory_malloc
DWALLOC_API_PUBLIC void * dwDynamicMemory_malloc(size_t const size)
Allocate chunk of memory using allocator passed through dwDynamicMemory_initialize().
DW_DYNAMIC_MEMORY_ALLOC_NOT_ALLOWED
@ DW_DYNAMIC_MEMORY_ALLOC_NOT_ALLOWED
Allocation is currently not allowed, because in runtime mode.
Definition: DynamicMemory.h:75
dwDynamicMemory_setErrorCallback
DWALLOC_API_PUBLIC void dwDynamicMemory_setErrorCallback(dwDynamicMemoryErrorCallback errorCallback, void *const userData)
Set error callback to be executed on an allocation/free during runtime mode.
dwDynamicMemory_release
DWALLOC_API_PUBLIC void dwDynamicMemory_release(void)
Release dwDynamicMemory.
void
typedef void(WFD_APIENTRY PFNWFDBINDSOURCETOPIPELINEWITHTIMESTAMPNV)(const WFDDevice device
dwDynamicMemory_initialize
DWALLOC_API_PUBLIC void dwDynamicMemory_initialize(dwDynamicMemoryMallocCallback mallocCallback, dwDynamicMemoryFreeCallback freeCallback, void *const userData)
Initialize dwDynamicMemory with user-defined callback for user space memory allocations.
DWALLOC_API_PUBLIC
#define DWALLOC_API_PUBLIC
Definition: DynamicMemory.h:60
DW_MODE_RUNTIME
@ DW_MODE_RUNTIME
Heap memory allocations trigger an error callback.
Definition: DynamicMemory.h:160