Maybe I'm misunderstanding the note. Does this mean that the bash source code (written in C, I assume) now uses its own `malloc` function instead of what is provided by the standard C library? Or is it saying that `malloc` is a command I can call in bash?
I assumed the latter, and couldn't figure out why I would need to manually allocate memory in a shell script.
I don't think you can compile bash without a libc. The idea is that back in the day systems didn't always come with a good malloc, so bash provided its own. These days, you want --without-bash-malloc on pretty much all modern systems (where "modern" means "last 20 years").
It was a good idea 30+ years ago, maybe. It's really old and crufty code; last time I checked it's all in pre-ANSI C and with workarounds for platforms like 1980s Xenix.
> Use the Bash version of malloc in the directory lib/malloc. This is not the same malloc that appears in GNU libc, but an older version originally derived from the 4.2 BSD malloc. This malloc is very fast, but wastes some space on each allocation. This option is enabled by default. The NOTES file contains a list of systems for which this should be turned off, and configure disables this option automatically for a number of systems.
> bash malloc has 8-byte alignment now, but I have no alphas to test on)
> next running NeXT/OS; machines running Openstep
> all machines running SunOS YP code: SunOS4, SunOS5, HP/UX, if you have problems with username completion or tilde expansion for usernames found via YP/NIS
> linux (optional, but don't do it if you're using Doug Lea's malloc)
> QNX 4.2
> other OSF/1 machines (KSR/1, HP, IBM AIX/ESA)
> AIX
> sparc SVR4, SVR4.2 (ICL reference port)
> DG/UX
> Cray
> Haiku OS
> NetBSD/sparc (malloc needs 8-byte alignment; bash malloc has 8-byte alignment now, but I have no NetBSD machines to test on)
> BSD/OS 2.1, 3.x if you want to use loadable builtins
> Motorola m68k machines running System V.3. There is a file descriptor leak caused by using the bash malloc because closedir(3) needs to read freed memory to find the file descriptor to close