From owner-freebsd-hackers Thu Aug 20 09:19:58 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id JAA04976 for freebsd-hackers-outgoing; Thu, 20 Aug 1998 09:19:58 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from rover.village.org (rover.village.org [204.144.255.49]) by hub.freebsd.org (8.8.8/8.8.8) with SMTP id JAA04947 for ; Thu, 20 Aug 1998 09:19:54 -0700 (PDT) (envelope-from imp@village.org) Received: from harmony [10.0.0.6] by rover.village.org with esmtp (Exim 1.71 #1) id 0z9XQa-0002hU-00; Thu, 20 Aug 1998 10:19:08 -0600 Received: from harmony.village.org (localhost.village.org [127.0.0.1]) by harmony.village.org (8.8.8/8.8.3) with ESMTP id KAA20970 for ; Thu, 20 Aug 1998 10:19:42 -0600 (MDT) Message-Id: <199808201619.KAA20970@harmony.village.org> To: hackers@FreeBSD.ORG Subject: Realloc fix for review Date: Thu, 20 Aug 1998 10:19:42 -0600 From: Warner Losh Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Recently, OpenBSD went through their source tree and fixed all instances of a = realloc(a, size); with na = realloc(a, size); if (!na) free(a); a = na; So rather than hack some really complicated a and na's, I write a new function, added it to libc and then modified all of src/lib to use this new function. I called it frealloc (freeing realloc). I added it to the man page, etc. I know that this isn't in ANSI C nor in POSIX, but after seeing how hard it was to get people to use strncpy right, I thought it would be good to add this to libc. I did a full make world, and this seems to work. One gotcha that I had was that I could not place frealloc into the "logical" place of malloc.c due to the "emacs malloc" problem that was worked around in ld.so. It was far easier to place it in its own file than to generate a working patch for ld.so. It also seems cleaner this way as well since the code will work with any implementation of malloc/free/realloc. Comments? Warner To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message