Thread safe memory allocation

parmi wrote on Tuesday, August 20, 2019:

thank you all for your help.
I solved the problem, in my code (main.cpp) I had only overridden the function ‘malloc_lock(…)’, I had forgotten to override the function ‘malloc_unlock(…)’, and then for some reason the linker gave me that error.
When I overridden both the function the problem was solved, the functions are called correctly every time I do a “new”, “delete”, “new[]”, “delete[]”, “malloc(…)”, "free (…) ", concatenate a long string, push back into a vector.

Also now I’m using “vTaskSuspendAll()” and “xTaskResumeAll()” instead of “vPortEnterCritical()”, “vPortExitCritical()”.
main.cpp

extern "C" void __malloc_lock(struct _reent *REENT)
{	
	vTaskSuspendAll();
}

extern "C" void __malloc_unlock(struct _reent *REENT)
{
	xTaskResumeAll();
}

Another request, can I replace “malloc(…)” with “pvPortMalloc (…)” and “free(…)” with “vPortFree(…)”?

I’m developing with VisualStudio 2019 with VisualGDB 5.4 on a SMT32F429ZI
p.s. attached is the image of the toolchain I am using