Memory redirection to connect external library

Hey guys, I have the typical situation of an external library (www.hotreload.tech) which needs have connected new/delete callbacks from the dll. If I use the following code I cannot even start the engine on Mac, and on Win64 I need to add weird things like if (isNotNullPtr), so arrives to Free nullptr pointers, which I think it’s strange.
void* UE4_Malloc(size_t size)
{
return FMemory::Malloc(size, DEFAULT_ALIGNMENT);
}

void UE4_Free(void* ptr)
{
	if (ptr)
		FMemory::Free(ptr);
}

What’s the proper way to redirect all memory allocations/deallocation in UE4?
Thanks a lot.