Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!lll-winken!elroy.jpl.nasa.gov!ncar!gatech!purdue!haven!adm!smoke!gwyn From: gwyn@smoke.brl.mil (Doug Gwyn) Newsgroups: comp.unix.questions Subject: Re: Shared memory and malloc Message-ID: <15035@smoke.brl.mil> Date: 31 Jan 91 21:34:00 GMT References: <14854@smoke.brl.mil> <951@scaxs2.pkinbg.uucp> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 23 In article <951@scaxs2.pkinbg.uucp> caxwgk@pkinbg.UUCP (Wolfgang Kuehnel ) writes: -From article <14854@smoke.brl.mil>, by gwyn@smoke.brl.mil (Doug Gwyn): -> In article <943@scaxs2.pkinbg.uucp> caxwgk@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 && ps.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.