Another thing I can't understand is why the code around
LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT is needed if:
* NO_SYS=1
* MEM_USE_POOLS=0
* MEM_LIBC_MALLOC=0
* SYS_LIGHTWEIGHT_PROT=1
* sys_arch_protect() simply disables interrupts
In mem_malloc there's a point where LWIP_MEM_ALLOC_PROTECT is called,
before the "scan through the heap searching for a free block". Why
during the scan, for each loop, UNPROTECT/PROTECT are called? The
comment says /* allow mem_free or mem_trim to run */.
Maybe this is done because the scan could take a long time to finish
(for big and fragmented heap) and having interrupts disabled for so long
time is not good? So the interrupts are enabled and disabled for each
loop to give them opportunity to run?