From owner-freebsd-hackers Thu Sep 18 14:17:43 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id OAA07448 for hackers-outgoing; Thu, 18 Sep 1997 14:17:43 -0700 (PDT) Received: from usr03.primenet.com (tlambert@usr03.primenet.com [206.165.6.203]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id OAA07431 for ; Thu, 18 Sep 1997 14:17:39 -0700 (PDT) Received: (from tlambert@localhost) by usr03.primenet.com (8.8.5/8.8.5) id OAA13613; Thu, 18 Sep 1997 14:14:41 -0700 (MST) From: Terry Lambert Message-Id: <199709182114.OAA13613@usr03.primenet.com> Subject: Re: Bug in malloc/free (was: Memory leak in getservbyXXX?) To: gram@cdsec.com (Graham Wheeler) Date: Thu, 18 Sep 1997 21:14:40 +0000 (GMT) Cc: phk@critter.freebsd.dk, gram@gram.cdsec.com, hackers@FreeBSD.ORG In-Reply-To: <199709181722.TAA00606@cdsec.com> from "Graham Wheeler" at Sep 18, 97 07:22:10 pm X-Mailer: ELM [version 2.4 PL23] Content-Type: text Sender: owner-freebsd-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > Well, then maybe you'll find the code below useful. It isn't Purify, but > then it doesn't cost anything near the price 8-). I'd use it > myself now, except that these days I write everything in C++. Mostly I'm > happy about that, but not right now... You can replace you "new" and "delete" functions; you knew that, right? [ ... ] > --------- gwtest.c ------------------------------------------------------ [ ... ] > void doubleFreeTest(void) > { > heap_ptr p = malloc(10); > free(p); > free(p); > } How about: heap_ptr p = malloc( 20); heap_ptr q, r; free(p); q = malloc(10) r = malloc( 10); free(p); ? 8-). Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers.