acadia-newlib/newlib/libc/stdlib
Torbjörn SVENSSON 0455ea28ce Used chunk needs to be removed from free_list
When using nano malloc and the remaning heap space is not big enough to
fullfill the allocation, malloc will attempt to merge the last chunk in
the free list with a new allocation in order to create a bigger chunk.
This is successful, but the chunk still remains in the free_list, so
any later call to malloc can give out the same region without it first
being freed.

Possible sequence to verify:

void *p1 = malloc(3000);
void *p2 = malloc(4000);
void *p3 = malloc(5000);
void *p4 = malloc(6000);
void *p5 = malloc(7000);
free(p2);
free(p4);
void *p6 = malloc(35000);
free(p6);
void *p7 = malloc(42000);
void *p8 = malloc(32000);

Without the change, p7 and p8 points to the same address.
Requirement, after malloc(35000), there is less than 42000 bytes
available on the heap.

Contributed by STMicroelectronics

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
2022-09-01 14:40:27 -04:00
..
Makefile.inc newlib: libc: merge build up a directory 2022-03-16 21:18:25 -04:00
_Exit.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
__adjust.c Add _REENT_ERRNO(ptr) 2022-07-13 06:55:41 +02:00
__atexit.c Use global atexit data for all configurations 2022-05-18 07:45:09 +02:00
__call_atexit.c Use global atexit data for all configurations 2022-05-18 07:45:09 +02:00
__exp10.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
__ten_mu.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
_mallocr.c newlib: rename mallocr.c to _mallocr.c 2022-03-09 04:12:46 -05:00
a64l.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
abort.c ansification: remove _VOID 2018-01-17 11:47:20 -06:00
abs.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
aligned_alloc.c Include malloc.h in libc/stdlib/aligned_alloc.c 2021-02-18 02:05:47 +01:00
arc4random.c Fix some Coverity Scan errors. 2022-08-31 15:18:08 -04:00
arc4random.h Only define static locks in multithreaded mode 2017-02-13 17:04:17 -05:00
arc4random_uniform.c Revert "sys/types.h: Don't include sys/_stdint.h" 2022-05-04 15:08:44 +02:00
assert.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
atexit.c ansification: remove _EXFNPTR, _EXPARM 2018-01-17 11:47:27 -06:00
atexit.h ansification: remove _PTR 2018-01-17 11:47:16 -06:00
atof.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
atoff.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
atoi.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
atol.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
atoll.c Use remove-advertising-clause script to edit BSD licenses 2020-01-29 19:03:31 +01:00
btowc.c Consolidate wctomb/mbtowc calls for POSIX-1.2008 2016-08-15 10:56:57 +02:00
calloc.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
callocr.c newlib: libc: move stdlib multiplex logic from build to source files 2022-03-09 16:58:46 -05:00
cfreer.c newlib: libc: move stdlib multiplex logic from build to source files 2022-03-09 16:58:46 -05:00
chacha_private.h
cxa_atexit.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
cxa_finalize.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
div.c Use remove-advertising-clause script to edit BSD licenses 2020-01-29 19:03:31 +01:00
drand48.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
dtoa.c Add --enable-newlib-reent-thread-local option 2022-07-13 06:55:46 +02:00
dtoastub.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
ecvtbuf.c Add --enable-newlib-reent-thread-local option 2022-07-13 06:55:46 +02:00
efgcvt.c fix compile errors for efgcvt.c 2019-07-24 11:58:21 +02:00
environ.c
envlock.c stdlib: remove TRAD_SYNOPSIS 2017-12-01 03:41:52 -06:00
eprintf.c
erand48.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
exit.c Add stdio_exit_handler() 2022-05-13 12:35:00 +02:00
freer.c newlib: libc: move stdlib multiplex logic from build to source files 2022-03-09 16:58:46 -05:00
gdtoa-dmisc.c ldtoa: Import gdtoa from OpenBSD. 2021-12-03 19:20:17 +09:00
gdtoa-gdtoa.c ldtoa: Import gdtoa from OpenBSD. 2021-12-03 19:20:17 +09:00
gdtoa-gethex.c stdlib: conditionalize locale usage 2021-08-23 10:02:00 +02:00
gdtoa-gmisc.c ldtoa: Import gdtoa from OpenBSD. 2021-12-03 19:20:17 +09:00
gdtoa-hexnan.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
gdtoa-ldtoa.c ldtoa: Import gdtoa from OpenBSD. 2021-12-03 19:20:17 +09:00
gdtoa.h ldtoa: Import gdtoa from OpenBSD. 2021-12-03 19:20:17 +09:00
gdtoaimp.h ldtoa: Import gdtoa from OpenBSD. 2021-12-03 19:20:17 +09:00
getenv.c Use remove-advertising-clause script to edit BSD licenses 2020-01-29 19:03:31 +01:00
getenv_r.c Use remove-advertising-clause script to edit BSD licenses 2020-01-29 19:03:31 +01:00
getopt.c newlib: getopt now permutes multi-flag options correctly 2018-06-18 18:45:44 +02:00
getsubopt.3 Use remove-advertising-clause script to edit BSD licenses 2020-01-29 19:03:31 +01:00
getsubopt.c Use remove-advertising-clause script to edit BSD licenses 2020-01-29 19:03:31 +01:00
imaxabs.c Importing imaxabs inttypes method from FreeBSD. 2017-07-28 12:23:08 +02:00
imaxdiv.c Importing imaxdiv inttypes method from FreeBSD. 2017-07-28 12:23:10 +02:00
itoa.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
jrand48.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
l64a.c Add --enable-newlib-reent-thread-local option 2022-07-13 06:55:46 +02:00
labs.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
lcong48.c Add --enable-newlib-reent-thread-local option 2022-07-13 06:55:46 +02:00
ldiv.c Use remove-advertising-clause script to edit BSD licenses 2020-01-29 19:03:31 +01:00
ldtoa.c ldtoa: Import gdtoa from OpenBSD. 2021-12-03 19:20:17 +09:00
llabs.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
lldiv.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
local.h ansification: remove _EXFUN, _EXFUN_NOTHROW 2018-01-17 11:47:29 -06:00
lrand48.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
malign.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
malignr.c newlib: libc: move stdlib multiplex logic from build to source files 2022-03-09 16:58:46 -05:00
mallinfor.c newlib: libc: move stdlib multiplex logic from build to source files 2022-03-09 16:58:46 -05:00
malloc.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
mallocr.c newlib: libc: move stdlib multiplex logic from build to source files 2022-03-09 16:58:46 -05:00
malloptr.c newlib: libc: move stdlib multiplex logic from build to source files 2022-03-09 16:58:46 -05:00
mallstatsr.c newlib: libc: move stdlib multiplex logic from build to source files 2022-03-09 16:58:46 -05:00
mbctype.h ansification: remove _EXFUN, _EXFUN_NOTHROW 2018-01-17 11:47:29 -06:00
mblen.c Add --enable-newlib-reent-thread-local option 2022-07-13 06:55:46 +02:00
mblen_r.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
mbrlen.c Add --enable-newlib-reent-thread-local option 2022-07-13 06:55:46 +02:00
mbrtowc.c Add --enable-newlib-reent-thread-local option 2022-07-13 06:55:46 +02:00
mbsinit.c
mbsnrtowcs.c Add --enable-newlib-reent-thread-local option 2022-07-13 06:55:46 +02:00
mbsrtowcs.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
mbstowcs.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
mbstowcs_r.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
mbtowc.c Add --enable-newlib-reent-thread-local option 2022-07-13 06:55:46 +02:00
mbtowc_r.c Add _REENT_ERRNO(ptr) 2022-07-13 06:55:41 +02:00
mlock.c stdlib: remove TRAD_SYNOPSIS 2017-12-01 03:41:52 -06:00
mprec.c Add --enable-newlib-reent-thread-local option 2022-07-13 06:55:46 +02:00
mprec.h ldtoa: Import gdtoa from OpenBSD. 2021-12-03 19:20:17 +09:00
mrand48.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
msize.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
msizer.c newlib: libc: move stdlib multiplex logic from build to source files 2022-03-09 16:58:46 -05:00
mstats.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
mtrim.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
nano-mallocr.c Used chunk needs to be removed from free_list 2022-09-01 14:40:27 -04:00
nrand48.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
on_exit.c ansification: remove _EXFNPTR, _EXPARM 2018-01-17 11:47:27 -06:00
on_exit_args.c
on_exit_args.h
putenv.c Use remove-advertising-clause script to edit BSD licenses 2020-01-29 19:03:31 +01:00
putenv_r.c Use remove-advertising-clause script to edit BSD licenses 2020-01-29 19:03:31 +01:00
pvallocr.c newlib: libc: move stdlib multiplex logic from build to source files 2022-03-09 16:58:46 -05:00
quick_exit.c Only define static locks in multithreaded mode 2017-02-13 17:04:17 -05:00
rand.c Add --enable-newlib-reent-thread-local option 2022-07-13 06:55:46 +02:00
rand48.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
rand48.h ansification: remove _EXFUN, _EXFUN_NOTHROW 2018-01-17 11:47:29 -06:00
rand_r.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
random.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
realloc.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
reallocarray.c libc/stdlib: Use __builtin_mul_overflow for reallocarray and calloc 2020-08-12 10:09:56 +02:00
reallocf.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
reallocr.c newlib: libc: move stdlib multiplex logic from build to source files 2022-03-09 16:58:46 -05:00
rpmatch.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
sb_charsets.c Actually return value from __cp_index 2016-10-22 21:08:44 +02:00
seed48.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
setenv.c Use remove-advertising-clause script to edit BSD licenses 2020-01-29 19:03:31 +01:00
setenv_r.c Use remove-advertising-clause script to edit BSD licenses 2020-01-29 19:03:31 +01:00
srand48.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
std.h ansification: remove _HAVE_STDC 2018-01-17 11:47:30 -06:00
stdlib.tex Add simple versions of random() and srandom() 2016-03-28 22:39:50 -05:00
strtod.c Add _REENT_ERRNO(ptr) 2022-07-13 06:55:41 +02:00
strtodg.c Prevent more NULL ptr accesses due to Balloc out of memory 2020-01-09 15:18:14 -05:00
strtoimax.c Add _REENT_ERRNO(ptr) 2022-07-13 06:55:41 +02:00
strtol.c Add _REENT_ERRNO(ptr) 2022-07-13 06:55:41 +02:00
strtold.c Implement strto[dflu]_l/wcsto[dflu]_l 2016-08-15 17:35:21 +02:00
strtoll.c Add _REENT_ERRNO(ptr) 2022-07-13 06:55:41 +02:00
strtoll_r.c Implement strto[dflu]_l/wcsto[dflu]_l 2016-08-15 17:35:21 +02:00
strtorx.c newlib: strtold: use __builtin_nanl to avoid libm dependency 2018-10-10 17:53:55 +02:00
strtoul.c Add _REENT_ERRNO(ptr) 2022-07-13 06:55:41 +02:00
strtoull.c Add _REENT_ERRNO(ptr) 2022-07-13 06:55:41 +02:00
strtoull_r.c Implement strto[dflu]_l/wcsto[dflu]_l 2016-08-15 17:35:21 +02:00
strtoumax.c Add _REENT_ERRNO(ptr) 2022-07-13 06:55:41 +02:00
system.c ansification: remove _EXFUN, _EXFUN_NOTHROW 2018-01-17 11:47:29 -06:00
utoa.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
valloc.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
vallocr.c newlib: libc: move stdlib multiplex logic from build to source files 2022-03-09 16:58:46 -05:00
wcrtomb.c Add --enable-newlib-reent-thread-local option 2022-07-13 06:55:46 +02:00
wcsnrtombs.c Add --enable-newlib-reent-thread-local option 2022-07-13 06:55:46 +02:00
wcsrtombs.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
wcstod.c Add _REENT_ERRNO(ptr) 2022-07-13 06:55:41 +02:00
wcstoimax.c Add _REENT_ERRNO(ptr) 2022-07-13 06:55:41 +02:00
wcstol.c Add _REENT_ERRNO(ptr) 2022-07-13 06:55:41 +02:00
wcstold.c stdlib: Use __get_numeric_locale instead of __localeconv_l for decimal_point 2018-09-06 14:14:05 +02:00
wcstoll.c Add _REENT_ERRNO(ptr) 2022-07-13 06:55:41 +02:00
wcstoll_r.c Implement strto[dflu]_l/wcsto[dflu]_l 2016-08-15 17:35:21 +02:00
wcstombs.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
wcstombs_r.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
wcstoul.c Add _REENT_ERRNO(ptr) 2022-07-13 06:55:41 +02:00
wcstoull.c Add _REENT_ERRNO(ptr) 2022-07-13 06:55:41 +02:00
wcstoull_r.c Implement strto[dflu]_l/wcsto[dflu]_l 2016-08-15 17:35:21 +02:00
wcstoumax.c Add _REENT_ERRNO(ptr) 2022-07-13 06:55:41 +02:00
wctob.c Consolidate wctomb/mbtowc calls for POSIX-1.2008 2016-08-15 10:56:57 +02:00
wctomb.c Add --enable-newlib-reent-thread-local option 2022-07-13 06:55:46 +02:00
wctomb_r.c Add _REENT_ERRNO(ptr) 2022-07-13 06:55:41 +02:00