heap: Fix race condition causing malloc() to fail under some conditions
heap: Fix race condition causing malloc() to fail under some conditions

During a call to multi_heap_malloc(), if both these conditions were true:
- That heap only has one block large enough for the allocation
  (this is always the case if the heap is unfragmented).
- Another allocation is simultaneously occurring in the same heap.

... multi_heap_malloc() could incorrectly return NULL.

This caused IDF heap_caps_malloc() and malloc() to also fail, particularly
often if only one or two heaps had space for the allocation (otherwise
heap_caps_malloc() fails over to the next heap).

empoweredhomes/esp-idf,Hermiedapwdrman/esp-idf,nineisk/esp-idf,mashaoze/esp-idf,MIhanguangyi/esp-idf,www220/esp-idf,armada-ai/esp-idf,espressif/esp-idf,espressif/esp-idf,www220/esp-idf,MIhanguangyi/esp-idf,espressif/esp-idf,armada-ai/esp-idf,shukyisme/esp-idf-kwik,mashaoze/esp-idf,empoweredhomes/esp-idf,Hermiedapwdrman/esp-idf,Hermiedapwdrman/esp-idf,mashaoze/esp-idf,shukyisme/esp-idf-kwik,Hermiedapwdrman/esp-idf,MIhanguangyi/esp-idf,shukyisme/esp-idf-kwik,empoweredhomes/esp-idf,www220/esp-idf,shukyisme/esp-idf-kwik,mashaoze/esp-idf,shukyisme/esp-idf-kwik,armada-ai/esp-idf,MIhanguangyi/esp-idf,mashaoze/esp-idf,MIhanguangyi/esp-idf,empoweredhomes/esp-idf,nineisk/esp-idf,Hermiedapwdrman/esp-idf,espressif/esp-idf,www220/esp-idf,www220/esp-idf,nineisk/esp-idf,empoweredhomes/esp-idf,armada-ai/esp-idf,nineisk/esp-idf