I have read similar threads on SO on this topic (How to initialize a Pointer to a struct in C? and Initializing a pointer to a structure) but failed trying new or malloc. I've got a bunch of typedefs like
typedef void (*STP_CALLBACK_ON_TOPOLOGY_CHANGED) (BRIDGE* bridge); typedef void* (*STP_CALLBACK_ALLOC_AND_ZERO_MEMORY) (unsigned int size); typedef void (*STP_CALLBACK_FREE_MEMORY) (void* p); typedef void (*STP_CALLBACK_ENABLE_LEARNING) (BRIDGE* bridge, unsigned int portIndex, unsigned int treeIndex, bool enable); which form a structure
struct STP_CALLBACKS { STP_CALLBACK_ON_TOPOLOGY_CHANGED onTopologyChanged; STP_CALLBACK_ALLOC_AND_ZERO_MEMORY allocAndZeroMemory; STP_CALLBACK_FREE_MEMORY freeMemory; ... }; and when I want to init a pointer to this structure with
const STP_CALLBACKS *callbacks = new STP_CALLBACKS; It actually inits nothing. I'm quite a newbie and obviously miss something important. What is a correct way to do it?
P.S. the code above is from mstp-lib. I'm on VS2015.