HomeFreeBSD

Remove some compatability with Seventh Edition UNIX realloc().

Description

Remove some compatability with Seventh Edition UNIX realloc().

In Seventh Edition UNIX, the last pointer passed to free() was
guaranteed to not actually have been freed allowing memory to be
"compacted" via the following pattern:

free(foo);
foo = realloc(foo, newsize);

Further, Andrew Koenig reports in "C Traps and Pitfalls" that the
original realloc() implementation required this pattern.

The C standard is clear that this is Undefined Behavior. Modern
allocators don't support it and no portable code could rely on it so
remove this support.

Note: the removed implementation contains an off-by-one error and if
an item isn't found on the freelist, then twice as much memory as the
largest possible allocation will be copied.

Reviewed by: kib, imp
Obtained from: CheriBSD
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D21296

Details

Provenance
brooksAuthored on
Reviewer
kib
Differential Revision
D21296: Remove some compatability with Seventh Edition UNIX realloc().
Parents
rS351250: Unbreak USB ethernet module builds
Branches
Unknown
Tags
Unknown