From owner-freebsd-arch@FreeBSD.ORG Sun Mar 26 11:11:20 2006 Return-Path: X-Original-To: freebsd-arch@FreeBSD.org Delivered-To: freebsd-arch@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6636B16A400; Sun, 26 Mar 2006 11:11:20 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [209.31.154.42]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0B53F43D45; Sun, 26 Mar 2006 11:11:19 +0000 (GMT) (envelope-from rwatson@FreeBSD.org) Received: from fledge.watson.org (fledge.watson.org [209.31.154.41]) by cyrus.watson.org (Postfix) with ESMTP id F190346C7B; Sun, 26 Mar 2006 06:11:18 -0500 (EST) Date: Sun, 26 Mar 2006 11:11:18 +0000 (GMT) From: Robert Watson X-X-Sender: robert@fledge.watson.org To: Jason Evans In-Reply-To: <442595E2.5080804@FreeBSD.org> Message-ID: <20060326110929.V35431@fledge.watson.org> References: <44247DF1.8000002@FreeBSD.org> <200603250806.k2P86YJU011861@apollo.backplane.com> <4424FDE9.3080707@FreeBSD.org> <20060325185612.GC7001@funkthat.com> <442595E2.5080804@FreeBSD.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: John-Mark Gurney , freebsd-arch@FreeBSD.org Subject: Re: Proposed addition of malloc_size_np() X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 26 Mar 2006 11:11:20 -0000 On Sat, 25 Mar 2006, Jason Evans wrote: >> Ok, so what you are saying is that the function returns the size of the >> bucket (if any) that the memory was allocated from... But even though this >> function may return a larger value, the program is not allowed to use extra >> space, and it's only useful for further allocations of the same size? > > I'm saying that malloc_size_np() returns the size of the allocation, to the > best of the allocator's knowledge. If you malloc(17), and malloc_size_np() > returns 32 for that allocation, then you can treat it as a 32-byte > allocation. However, the malloc implementation could conceivably return any > value >=17. I wonder if the intuitive objection people are raising is actually with the name. Since malloc_size() is defined on at least one platform to return the requested size, maybe a name like malloc_allocated_size() (or something a bit more compact) would help avoid that confusion, and make it clear that the consumer is getting back a commitment and not a hint for future realloc(), etc. Robert N M Watson