Realloc for Storage Compaction
Alan S. Watt
swatt at ittvax.UUCP
Wed Nov 30 06:53:10 AEST 1983
In V7 and 4.1, "diff" uses these strange properties. It also depends
on the fact that memory released via "free" is not modified until
the next "malloc" call.
The term "compacting reallocation" is misleading as memory is not
compacted in the usual sense of the word. What does happen is that
the memory block is joined with adjacent blocks if they are free.
If you're about to try out alternate implementations of "malloc" and
friends, be aware that the following programs use "realloc" in some
form or another:
/usr/src/cmd:
cron.c
nm.c
.../cifplot:
alloc.c
.../csh: (has its own copy of malloc.c)
alloc.c
.../diff:
diff.c
.../oldcsh: (has its own copy of malloc.c)
alloc.c
.../oldcsh: (has its own copy of malloc.c)
malloc.c
.../struct:
0.parts.c
To my knowledge, only "diff" depends on realloc's strange properties.
My notes on 4.2 state that the "malloc" routines are identical to those
in 4.1, but that a new version was received and available for use.
The diff as distributed in 4.1 will break if you substitute a scheme
which alters memory on free operations.
- Alan S. Watt
More information about the Comp.unix.wizards
mailing list