DriveWorks SDK Reference
5.12.103 Release
For Test and Development only

DynamicMemory.h
Go to the documentation of this file.
1
2//
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
59extern "C" {
60#endif
61
71
72typedef void* (*dwDynamicMemoryMallocCallback)(size_t sizeInByte, void* userData);
73typedef void (*dwDynamicMemoryFreeCallback)(void* addr, void* userData);
74typedef void (*dwDynamicMemoryErrorCallback)(dwDynamicMemoryError error, size_t lastRequestedSizeInByte, void* userData);
75
89 dwDynamicMemoryFreeCallback freeCallback,
90 void* const userData);
91
99void dwDynamicMemory_setErrorCallback(dwDynamicMemoryErrorCallback errorCallback, void* const userData);
100
111 dwDynamicMemoryFreeCallback* const freeCallback,
112 void** const userData);
113
118typedef enum dwRuntimeMode {
119 DW_MODE_INIT = 0x0000,
122 DW_MODE_COUNT = 3
124
137
147
154
164void* dwDynamicMemory_malloc(size_t const size);
165
172void dwDynamicMemory_free(void* const ptr);
173
174#ifdef __cplusplus
175}
176#endif
178#endif // DW_CORE_DYNAMIC_MEMORY_H_
#define DWALLOC_API_PUBLIC
Definition: DynamicMemory.h:55
DWALLOC_API_PUBLIC bool dwDynamicMemory_getRuntimeMode(dwRuntimeMode *const mode)
Return currently selected runtime mode.
DWALLOC_API_PUBLIC void dwDynamicMemory_release()
Release dwDynamicMemory.
DWALLOC_API_PUBLIC bool dwDynamicMemory_setRuntimeMode(dwRuntimeMode const newMode)
Switch runtime mode for all Driveworks SDK.
DWALLOC_API_PUBLIC void dwDynamicMemory_initialize(dwDynamicMemoryMallocCallback mallocCallback, dwDynamicMemoryFreeCallback freeCallback, void *const userData)
Initialize dwDynamicMemory with user-defined callback for user space memory allocations.
void(* dwDynamicMemoryErrorCallback)(dwDynamicMemoryError error, size_t lastRequestedSizeInByte, void *userData)
Definition: DynamicMemory.h:74
void(* dwDynamicMemoryFreeCallback)(void *addr, void *userData)
Definition: DynamicMemory.h:73
void *(* dwDynamicMemoryMallocCallback)(size_t sizeInByte, void *userData)
Definition: DynamicMemory.h:72
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.
DWALLOC_API_PUBLIC void dwDynamicMemory_free(void *const ptr)
Release memory chunk previously allocated with dwDynamicMemory_malloc().
dwRuntimeMode
Context runtime mode.
dwDynamicMemoryError
Error to be reported through error callback.
Definition: DynamicMemory.h:65
DWALLOC_API_PUBLIC void dwDynamicMemory_setErrorCallback(dwDynamicMemoryErrorCallback errorCallback, void *const userData)
Set error callback to be executed on an allocation error.
DWALLOC_API_PUBLIC void * dwDynamicMemory_malloc(size_t const size)
Allocate chunk of memory using allocator passed through dwDynamicMemory_initialize().
@ DW_MODE_COUNT
@ DW_MODE_CLEANUP
Heap memory allocations and deallocations are allowed.
@ DW_MODE_INIT
Heap memory allocations and deallocations are allowed. Default.
@ DW_MODE_RUNTIME
Heap memory allocations are not allowed.
@ DW_DYNAMIC_MEMORY_ALLOC_NOT_ALLOWED
Allocation is currently not allowed, because in runtime mode.
Definition: DynamicMemory.h:68
@ DW_DYNAMIC_MEMORY_SUCCESS
no error
Definition: DynamicMemory.h:66
@ DW_DYNAMIC_MEMORY_FREE_NOT_ALLOWED
Memory release is currently not allowed, because in runtime mode.
Definition: DynamicMemory.h:69
@ DW_DYNAMIC_MEMORY_BAD_ALLOC
Memory allocation failed, probably not enough memory.
Definition: DynamicMemory.h:67