From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2579 Path: news.gmane.org!not-for-mail From: Igmar Palsenberg Newsgroups: gmane.linux.lib.musl.general Subject: malloc(0) behaviour Date: Mon, 14 Jan 2013 18:17:47 +0100 Message-ID: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (Mac OS X Mail 6.2 \(1499\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1358183882 29953 80.91.229.3 (14 Jan 2013 17:18:02 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 14 Jan 2013 17:18:02 +0000 (UTC) To: "musl@lists.openwall.com" Original-X-From: musl-return-2580-gllmg-musl=m.gmane.org@lists.openwall.com Mon Jan 14 18:18:21 2013 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1Tunfs-00041A-J9 for gllmg-musl@plane.gmane.org; Mon, 14 Jan 2013 18:18:16 +0100 Original-Received: (qmail 28159 invoked by uid 550); 14 Jan 2013 17:17:59 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 28151 invoked from network); 14 Jan 2013 17:17:59 -0000 X-Mailer: Apple Mail (2.1499) Xref: news.gmane.org gmane.linux.lib.musl.general:2579 Archived-At: Hi, Is there a (good) reason for Musl to follow glibc's malloc(0) behaviour = ? Musl returns a valid pointer, which is fine according to the standard, but returning NULL is also fine. IMHO, returning NULL is better : It usually kills the program if actual = storage is attempted. You also can't do that if a valid pointer is returned, so I really can't grasp the reason for returning a pointer = at all, except to support buggy and lazy programming. I suggest we make malloc(0) return a NULL pointer. Any objections ? Regards, Igmar=