From owner-freebsd-arch@FreeBSD.ORG Sat Mar 25 08:07:41 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 C6C8816A41F for ; Sat, 25 Mar 2006 08:07:41 +0000 (UTC) (envelope-from jasone@FreeBSD.org) Received: from lh.synack.net (lh.synack.net [204.152.188.37]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7661143D46 for ; Sat, 25 Mar 2006 08:07:41 +0000 (GMT) (envelope-from jasone@FreeBSD.org) Received: by lh.synack.net (Postfix, from userid 100) id 55A4B5E4911; Sat, 25 Mar 2006 00:07:41 -0800 (PST) Received: from [192.168.168.201] (moscow-cuda-gen2-68-64-60-20.losaca.adelphia.net [68.64.60.20]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by lh.synack.net (Postfix) with ESMTP id 7158B5E4906; Sat, 25 Mar 2006 00:07:40 -0800 (PST) Message-ID: <4424FA4B.5080201@FreeBSD.org> Date: Sat, 25 Mar 2006 00:07:39 -0800 From: Jason Evans User-Agent: Mozilla Thunderbird 1.0.7-1.4.1 (X11/20050929) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Poul-Henning Kamp References: <62732.1143272796@critter.freebsd.dk> In-Reply-To: <62732.1143272796@critter.freebsd.dk> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Checker-Version: SpamAssassin 3.0.5 (2005-11-28) on lh.synack.net X-Spam-Level: * X-Spam-Status: No, score=1.8 required=5.0 tests=RCVD_IN_NJABL_DUL, RCVD_IN_SORBS_DUL autolearn=no version=3.0.5 Cc: 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: Sat, 25 Mar 2006 08:07:41 -0000 Poul-Henning Kamp wrote: > In message <44247DF1.8000002@FreeBSD.org>, Jason Evans writes: > >>=== Proposal === >>Add malloc_size_np() to libc, and provide the prototype in malloc_np.h: >> >> size_t >> malloc_size_np(const void *ptr); > > > I'm for the concept, but wonder if it would be smarter to make it > > void * > malloc_np(size_t, size_t *) > > so we can do it in one go ? I can see how this would be useful, but I don't think it completely replaces the use case for malloc_size_np(), which can be useful at other times than allocation/deallocation (ex: assertions that detect buffer overflow). Also, if we add malloc_np(), for completeness we should also provide: void * calloc_np(size_t size, size_t *size_ceil); void * realloc_np(void *ptr, size_t size, size_t *size_ceil); (Let's ignore posix_memalign() here.) size_t free_np(void *ptr); Given that these functions are essentially the (somewhat higher performance) fusion of two function calls, it isn't clear to me whether it's worth adding several extra functions. Personally, I would use them if they were available, but I'm not sure if they would be broadly useful. Thoughts? Thanks, Jason