teremok
(Andrew Teremkov)
March 12, 2022, 8:04pm
1
When using the module, we periodically observe that the canardFree is trying to release the null pointer.
canardAlloc: 30688416 bytes: 40
canardFree: 30688416
canardAlloc: 31360032 bytes: 32
canardAlloc: 30720600 bytes: 12
canardFree nullptr
Can you tell me how to solve this problem? We use version 1.1
This is not a problem. Freeing a null pointer is a no-op, and it is well-specified.
/// - The memory shall be aligned at least at max_align_t.
/// - The execution time should be constant (O(1)).
/// - The worst-case memory fragmentation should be bounded and easily predictable.
/// If the standard dynamic memory manager of the target platform does not satisfy the above requirements,
/// consider using O1Heap: https://github.com/pavel-kirienko/o1heap.
typedef void* (*CanardMemoryAllocate)(CanardInstance* ins, size_t amount);
/// The counterpart of the above -- this function is invoked to return previously allocated memory to the allocator.
/// The semantics are similar to free():
/// - The pointer was previously returned by the allocation function.
/// - The pointer may be NULL, in which case the function shall have no effect.
/// - The execution time should be constant (O(1)).
typedef void (*CanardMemoryFree)(CanardInstance* ins, void* pointer);
/// This is the core structure that keeps all of the states and allocated resources of the library instance.
struct CanardInstance
{
/// User pointer that can link this instance with other objects.
/// This field can be changed arbitrarily, the library does not access it after initialization.
/// The default value is NULL.
void* user_reference;