From owner-freebsd-current Fri Nov 22 7:33:51 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4B15E37B401 for ; Fri, 22 Nov 2002 07:33:50 -0800 (PST) Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.86.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7DA9243EAA for ; Fri, 22 Nov 2002 07:33:49 -0800 (PST) (envelope-from phk@critter.freebsd.dk) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.12.6/8.12.6) with ESMTP id gAMFXi76017193; Fri, 22 Nov 2002 16:33:45 +0100 (CET) (envelope-from phk@critter.freebsd.dk) To: Marc Recht Cc: freebsd-current@FreeBSD.ORG Subject: Re: malloc(0) broken? In-Reply-To: Your message of "Fri, 22 Nov 2002 16:25:20 +0100." <79620000.1037978720@leeloo.intern.geht.de> Date: Fri, 22 Nov 2002 16:33:44 +0100 Message-ID: <17192.1037979224@critter.freebsd.dk> From: Poul-Henning Kamp Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG In message <79620000.1037978720@leeloo.intern.geht.de>, Marc Recht writes: >Hi! > >A malloc(0) returns always 0x800 on my system. This causes some third-party >software to fail, because they expect malloc(0) to return NULL. Is this a >bug or a feature? malloc(3) doesn't mention anything. Then you didnt read malloc(3) well enough: V Attempting to allocate zero bytes will return a NULL pointer instead of a valid pointer. (The default behavior is to make a minimal allocation and return a pointer to it.) This option is provided for System V compatibility. This option is incompatible with the ``X'' option. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message