From owner-freebsd-net@FreeBSD.ORG Sat Feb 21 11:35:19 2004 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 224A616A4CE; Sat, 21 Feb 2004 11:35:19 -0800 (PST) Received: from rms04.rommon.net (rms04.rommon.net [212.54.2.140]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8A66743D1D; Sat, 21 Feb 2004 11:35:18 -0800 (PST) (envelope-from pete@he.iki.fi) Received: from he.iki.fi (h81.vuokselantie10.fi [193.64.42.129]) by rms04.rommon.net (8.12.9p1/8.12.9) with ESMTP id i1LJZEcM009138; Sat, 21 Feb 2004 21:35:14 +0200 (EET) (envelope-from pete@he.iki.fi) Message-ID: <4037B2E8.8070407@he.iki.fi> Date: Sat, 21 Feb 2004 21:35:04 +0200 From: Petri Helenius User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040113 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Maxime Henrion References: <40378E93.3010804@rommon.com> <20040221170635.GL35475@elvis.mu.org> In-Reply-To: <20040221170635.GL35475@elvis.mu.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit cc: FreeBSD - net Subject: Re: malloc (0) X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Feb 2004 19:35:19 -0000 Maxime Henrion wrote: >In C99, malloc(0) is legal. From n869.txt : > >%% >If the size of the space requested is zero, the behavior is >implementation-defined: either a null pointer is returned, >or the behavior is as if the size were some nonzero value, >except that the returned pointer shall not be used to >access an object. >%% > >As a side note, free(NULL) is also legal in C99. > > > I´m actually aware how the standard approaches the issue, but my question was more directed to how FreeBSD "code style" approaches the issue. Personally I feel that debugging would be easier if mallocing 0 bytes and free and realloc of NULL pointers would not spread. Pete