From owner-freebsd-arch@FreeBSD.ORG Sat Mar 25 08:19:30 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 103AE16A400; Sat, 25 Mar 2006 08:19:30 +0000 (UTC) (envelope-from phk@critter.freebsd.dk) Received: from pasmtp.tele.dk (pasmtp.tele.dk [193.162.159.95]) by mx1.FreeBSD.org (Postfix) with ESMTP id A70EA43D46; Sat, 25 Mar 2006 08:19:27 +0000 (GMT) (envelope-from phk@critter.freebsd.dk) Received: from critter.freebsd.dk (0x535c0e2a.sgnxx1.adsl-dhcp.tele.dk [83.92.14.42]) by pasmtp.tele.dk (Postfix) with ESMTP id 64A861EC30C; Sat, 25 Mar 2006 09:19:26 +0100 (CET) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.13.4/8.13.4) with ESMTP id k2P8JNCJ062922; Sat, 25 Mar 2006 09:19:25 +0100 (CET) (envelope-from phk@critter.freebsd.dk) To: Peter Jeremy From: "Poul-Henning Kamp" In-Reply-To: Your message of "Sat, 25 Mar 2006 19:10:38 +1100." <20060325081037.GC703@turion.vk2pj.dyndns.org> Date: Sat, 25 Mar 2006 09:19:23 +0100 Message-ID: <62921.1143274763@critter.freebsd.dk> Sender: phk@critter.freebsd.dk Cc: Jason Evans , 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:19:30 -0000 In message <20060325081037.GC703@turion.vk2pj.dyndns.org>, Peter Jeremy writes: >On Sat, 2006-Mar-25 08:46:36 +0100, 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 ? > >That restricts its use to malloc() wrappers. I can also see the >benefit in a function trying to validate the size of an arbitrary >piece of memory that has been passed to it. No you can't, because you cannot be certain that the pointer passed to you is actually an unadultered malloc pointer. -- 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.