In this release, instead of using “new” to allocate heap memory in xAF interface classes, pointers to memory allocator and de-allocator methods are now passed in during initialization:
typedef void* (*memAlloc)(unsigned int, unsigned int);
typedef void (*memDeAlloc)(void*);
This was done for the following classes/structs:
Master Control:
When calling xAFInitMasterControl, the application now needs to pass in an allocator pointer, alloc.
enum xAF_Error xAFInitMasterControl(xAFSMasterControl* p_masterControl, unsigned int* ControlConfig, unsigned int maxPins, unsigned int maxXafInstance, memAlloc alloc);
memAlloc is simply a pointer to a memory allocation method defined by the application:
Similarly, for deallocation, a de-allocation memory pointer needs to also be passed in:
void xAFDeallocMasterControl(xAFSMasterControl* p_masterControlstruct, memDeAlloc deAlloc);
Chunk Parser:
ChunkParser is the base class that multiple parsing classes inherit from including DSFDParser and DeviceParser. When initializing it, the application has to pass both allocator and de-allocator pointers:
xAF_Error init(IOBase* theInterface, char(&identifierString)[4], memAlloc allocator, memDeAlloc deAllocator);
Initialization Message Parser:
This class is responsible for saving the xTP signal flow data into flash/persistent memory on an amplifier. Accordingly, a memory allocator needs to be passed into the method that allows the parser to access the flash memory:
typedef FlashInterface* (*openMemoryStorage_t)(memAlloc alloc, flashfileType type, unsigned int coreID, unsigned int instanceID, IOBase::AccessMode mode);
The allocator and deallocators also need to be passed into the method to initialize the parser:
xAF_Error initParser(openMemoryStorage_t openPtr, memAlloc allocator, memDeAlloc deAllocator);