DLL Boundary Safe Memory Management
Passing pointers across DLL boundaries could lead to heap corruption if the DLLs use different runtimes. Each runtime has its own heap manager, so attempting to free memory in a DLL that was allocated in a different DLL is unsafe (source). However it is desirable to be able to pass pointers, or objects that contain pointers (such as a string), across DLL boundaries. In order to achieve this, Carbonite provides memory management functions that are DLL-boundary-safe.
There are three available functions:
carb::reallocate(). These functions are analogous to malloc, free, and realloc. These functions all use
an internal memory management function in
carbReallocate()), so that all allocations and deallocations use the same C Runtime, and thus
are safe for use by different plugins.