Sometimes the application calls pvPortMalloc with xWantedSize = 0, just for code simplification.
If then configUSE_MALLOC_FAILED_HOOK is enabled, it calls vApplicationMallocFailedHook.
My recommendation is to call vApplicationMallocFailedHook only if xWantedSize > 0.
Can you not add a check to not call pvPortMalloc when xWantedSize is 0?
For sure I could, but as I said, sometimes the code is simpler to just ask for 0 bytes. I mean the pvPortMalloc is made to ask 0 bytes. It was just a wish.
My understanding is that pvPortMalloc does NOT have the same definition a malloc, that allows calling it with a zero size valid.
The simple solution, write a simple wrapper that you call that checks the size request, and if zero just returns the NULL, and if not calls the actual pvPortMalloc routine.
Easy. I know all these possible solutions, I have already solved it.
I just thought, because the function itself checks also:
if( xWantedSize > 0 )
I am positively certain that once that happens, someone who relied on the current behavior will complain because of broken backward compatibility, so if I were in charge, I would not implement it.