What happens during an unlink(2) - really malloc()

#Bill_Stewart wcs at ho95e.UUCP
Thu May 1 06:51:49 AEST 1986


In article <422 at ukecc.UUCP> edward at ukecc.UUCP (Edward C. Bennett) writes:
>
>>.....[stuff about what happens to blocks when you unlink the file]...
>        When the old data blocks are placed in the free list, their contents
>are unimportant. Zeroing the blocks would be a waste of time since whatever
>is there will be overwritten when the blocks are allocated to another file.
>This situation is identical to the malloc()/free() process. i.e. Space
>that has been malloc()ed will have data written into it. When this space
>is free()ed, the data in it is not altered and is useable until the next
>malloc().

Please don't depend on this behaviour!  Under the older mallocs (including
System V and 4.1BSD), you could depend on it, but systems with newer and
fancier mallocs don't promise it.  In particular, System V Release 2 offers
two malloc routines.  The default is the old malloc, but the new -lmalloc
library provides routines that offer better performance under some kinds of
input, and the man page says you can't trust freed-up memory after a free()
or realloc().

In general, the safety of using freed space depends on the implementation of
the data structures chaining space together.
-- 
# Bill Stewart, AT&T Bell Labs 2G-202, Holmdel NJ 1-201-949-0705 ihnp4!ho95c!wcs



More information about the Comp.unix.wizards mailing list