diff options
author | Simon Glass <sjg@chromium.org> | 2024-07-30 08:39:35 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2024-08-07 08:49:10 -0600 |
commit | 04894f5ad53cab0ee03eb3bc1cc1682e22f5dd1b (patch) | |
tree | 9dd6e83984ac9d1f633bda441591573d2ce1f5b7 /common/dlmalloc.c | |
parent | c0d269da3c8492d4b81bbcb79a66f6d4a49f7610 (diff) |
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>
Diffstat (limited to 'common/dlmalloc.c')
-rw-r--r-- | common/dlmalloc.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/common/dlmalloc.c b/common/dlmalloc.c index 62e8557daa7..1e1602a24de 100644 --- a/common/dlmalloc.c +++ b/common/dlmalloc.c @@ -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); |