Shared memory and malloc

Doug Gwyn gwyn at smoke.brl.mil
Fri Feb 1 08:34:00 AEST 1991


In article <951 at scaxs2.pkinbg.uucp> caxwgk at pkinbg.UUCP (Wolfgang Kuehnel  ) writes:
-From article <14854 at smoke.brl.mil>, by gwyn at smoke.brl.mil (Doug Gwyn):
-> In article <943 at scaxs2.pkinbg.uucp> caxwgk at pkinbg.UUCP (Wolfgang Kuehnel  ) writes:
->>beware of a bug in K+R free()-function, at least in the german translation
-> There were no bugs in the malloc()/free() implementation in the second
-> edition of K&R, at least not as of the time when I reviewed the draft.
-> However, there were a few subtleties.
-void free(ap)
-char *ap; 
-{
-register header *p,*q;
- 
- p = (header *)ap;
- p = p - 1;                                      /* auf Beschreibung zeigen */
- for (q=allocp;!(p>q && p<q->s.ptr);q=q->s.ptr)
- /*                              Das ^ ist ein "-" in Kernighan/Ritchie */
-The '=' marked above is printed '-' in K+R of Hanser Verlag in Germany. ...
-That's not a subtlety, I think.

That appears to be a MODIFIED version of the code from K&R 1st Edition;
I have no idea who modified the code or why, but the bug does not appear
in the second printing of the 1st Edition nor in the (corresponding but
substantially different) code in the first printing of the 2nd Edition.



More information about the Comp.unix.questions mailing list