Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762660AbXFBCKi (ORCPT ); Fri, 1 Jun 2007 22:10:38 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1759276AbXFBCKb (ORCPT ); Fri, 1 Jun 2007 22:10:31 -0400 Received: from seahorse.shentel.net ([204.111.1.244]:55686 "EHLO seahorse.shentel.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758877AbXFBCKa (ORCPT ); Fri, 1 Jun 2007 22:10:30 -0400 Date: Fri, 1 Jun 2007 22:09:35 -0400 (EDT) From: "John Anthony Kazos Jr." To: Christoph Lameter cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, Linus Torvalds , Jeremy Fitzhardinge Subject: Re: SLUB: Return ZERO_SIZE_PTR for kmalloc(0) In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1152 Lines: 23 > + * The behavior for zero sized allocs changes. We no longer > + * allocate memory but return ZERO_SIZE_PTR. > + * WARN so that people can review and fix their code. I don't see why people have so much opposition to zero-size memory allocations. There's all sorts of situations where you want a resizeable array that may have zero objects, especially in these days of hotpluggability. Not only is it simpler (and therefore less likely to be buggy) to write code to simply resize to current number of objects, but not having to make additional code for checking the special case of count==0 leading to different function calls (instead of always reallocating, you might have to allocate instead, and instead of reallocating to zero you might have to free instead) will very slightly increase the object-text size. The standard-C behavior of valid zero-size allocation has a very good reason. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/