DriveWorks SDK Reference

| 0.6.67 Release

Core Dynamic Memory

Detailed Description

Processes wide dynamic memory API.

Typedefs

typedef void(* dwDynamicMemoryFreeCallback) (void *addr, void *userData)
 
typedef void *(* dwDynamicMemoryMallocCallback) (size_t sizeInByte, void *userData)
 

Enumerations

enum  dwRuntimeMode {
  DW_MODE_INIT = 0x0000,
  DW_MODE_RUNTIME = 0x0001,
  DW_MODE_CLEANUP = 0x0002
}
 Context runtime mode. More...
 

Functions

DW_API_PUBLIC dwStatus dwDynamicMemory_getCallbacks (dwDynamicMemoryMallocCallback *mallocCallback, dwDynamicMemoryFreeCallback *freeCallback, void **userData)
 Get callbacks and user-defined general pointer previously passed in dwDynamicMemory_initialize. More...
 
DW_API_PUBLIC dwStatus dwDynamicMemory_initialize (dwDynamicMemoryMallocCallback mallocCallback, dwDynamicMemoryFreeCallback freeCallback, void *userData)
 Initialize dwDynamicMemory with user-defined callback for user space memory allocations. More...
 
DW_API_PUBLIC dwStatus dwDynamicMemory_release ()
 Release dwDynamicMemory. More...
 
DW_API_PUBLIC dwStatus dwDynamicMemory_updateRuntimeMode (dwRuntimeMode newMode)
 Switch runtime mode for all Driveworks SDK. More...
 
DW_API_PUBLIC void * memcpy_opt (void *__restrict destination, const void *__restrict source, size_t num)
 Memory copy of virtual process memory. More...
 

Typedef Documentation

◆ dwDynamicMemoryFreeCallback

typedef void(* dwDynamicMemoryFreeCallback) (void *addr, void *userData)

Definition at line 62 of file DynamicMemory.h.

◆ dwDynamicMemoryMallocCallback

typedef void*(* dwDynamicMemoryMallocCallback) (size_t sizeInByte, void *userData)

Definition at line 61 of file DynamicMemory.h.

Enumeration Type Documentation

◆ dwRuntimeMode

Context runtime mode.

Enumerator
DW_MODE_INIT 

Heap memory allocations and deallocations are allowed. Default.

DW_MODE_RUNTIME 

Heap memory allocations are not allowed.

DW_MODE_CLEANUP 

Heap memory allocations and deallocations are allowed.

Definition at line 97 of file DynamicMemory.h.

Function Documentation

◆ dwDynamicMemory_getCallbacks()

DW_API_PUBLIC dwStatus dwDynamicMemory_getCallbacks ( dwDynamicMemoryMallocCallback mallocCallback,
dwDynamicMemoryFreeCallback freeCallback,
void **  userData 
)

Get callbacks and user-defined general pointer previously passed in dwDynamicMemory_initialize.

Optionally pass NULL if not interested in retrieving the pointers

Parameters
[out]mallocCallbackreturned by pointer address of the mallocCallback.
[out]freeCallbackreturned by pointer address of the freeCallback.
[out]userDatareturned by pointer value of previously passed userData during initialization.
Returns
DW_SUCCESS

◆ dwDynamicMemory_initialize()

DW_API_PUBLIC dwStatus dwDynamicMemory_initialize ( dwDynamicMemoryMallocCallback  mallocCallback,
dwDynamicMemoryFreeCallback  freeCallback,
void *  userData 
)

Initialize dwDynamicMemory with user-defined callback for user space memory allocations.

If initialization is not performed or if user provides NULL pointers for the callbacks then CRT heap allocation routines will be used.

Parameters
[in]mallocCallbackfunctions which will be used for memory allocation. NULL for CRT implementation
[in]freeCallbackfunctions which will be used for memory deallocation. NULL for CRT implementation
[in]userDatageneral pointer to something understandable by mallocCallback or freeCallback
Returns
DW_SUCCESS

◆ dwDynamicMemory_release()

DW_API_PUBLIC dwStatus dwDynamicMemory_release ( )

Release dwDynamicMemory.

After this call all following requests for memory allocation will use the CRT heap allocation mechanisms.

Returns
DW_SUCCESS

◆ dwDynamicMemory_updateRuntimeMode()

DW_API_PUBLIC dwStatus dwDynamicMemory_updateRuntimeMode ( dwRuntimeMode  newMode)

Switch runtime mode for all Driveworks SDK.

A runtime mode is activated after full initialization phase. Switching to runtime mode allows context to perform checks if for example heap allocations are still hapenning. Runtime mode does not have any effect on the performance of the SDK modules, it can, however, used for debugging purpose.

Parameters
[in]newModemode that you want to setup
Returns
DW_INVALID_ARGUMENT if context handle is NULL or the selected device doesn't exist.
DW_SUCCESS

◆ memcpy_opt()

DW_API_PUBLIC void* memcpy_opt ( void *__restrict  destination,
const void *__restrict  source,
size_t  num 
)

Memory copy of virtual process memory.

This subroutine call standard memcpy for x86_64, and custom optimized implementation for aarch64. As in standart memcpy call destination and source memory blocks should not overlap.

Parameters
[out]destinationpointer to destination memory into which num bytes will be copied from source
[in]sourcepointer to source memory which will be copied destination
[in]numnumber of bytes to copy
Returns
pointer to destination