malloc: Support testing with realloc()

At present in tests it is possible to cause an out-of-memory condition
with malloc() but not realloc(). Add support to realloc() too, so code
which uses that function can be tested.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2024-07-30 08:39:35 -06:00
committed by Tom Rini
parent c0d269da3c
commit 04894f5ad5

View File

@@ -1698,6 +1698,10 @@ Void_t* rEALLOc_impl(oldmem, bytes) Void_t* oldmem; size_t bytes;
panic("pre-reloc realloc() is not supported");
}
#endif
if (CONFIG_IS_ENABLED(UNIT_TEST) && malloc_testing) {
if (--malloc_max_allocs < 0)
return NULL;
}
newp = oldp = mem2chunk(oldmem);
newsize = oldsize = chunksize(oldp);