From owner-freebsd-current@FreeBSD.ORG Thu Nov 28 11:17:59 2013 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9B5AD857 for ; Thu, 28 Nov 2013 11:17:59 +0000 (UTC) Received: from mail-lb0-x235.google.com (mail-lb0-x235.google.com [IPv6:2a00:1450:4010:c04::235]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 26457175A for ; Thu, 28 Nov 2013 11:17:58 +0000 (UTC) Received: by mail-lb0-f181.google.com with SMTP id q8so6009195lbi.40 for ; Thu, 28 Nov 2013 03:17:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:date:message-id:subject:from:to:content-type; bh=SifdWtsMTFaSY1s4ytk9V8Z7r1diUauXug+cJoD8ExM=; b=gar26gckzSZG4bXGWgXJWSQWsX4KD9sPPXf9fa+dLEhanOJYepgYU7YdVvE4HGkgrG h9d+cR9hAGLcnETTtzfHE4Q8dvhg0FXeVLgWRPFUsp7kLrk8dyGeXxHtuoMEbfblB+uV uhgwXTyLgi/m1jttgs12RP0dhcvkPoDziJSTqHEnWubiKEo4JQ/yMkl6jLiyZjGxFbHm CL0auUB0iKuz+6XFnBpkAVp9N53iyfGArtAyFfgCUiaLBlR2uBA3cY+G6NcDy7IzIB0g TbPybxUrjyiCA8ujo5aWDghvFWoy/UpbDRca2KhgWFXbIpqtTostHl3xsE4dbyQk5QBR Qacw== MIME-Version: 1.0 X-Received: by 10.112.141.166 with SMTP id rp6mr4236668lbb.39.1385637477048; Thu, 28 Nov 2013 03:17:57 -0800 (PST) Sender: rizzo.unipi@gmail.com Received: by 10.114.175.180 with HTTP; Thu, 28 Nov 2013 03:17:56 -0800 (PST) Date: Thu, 28 Nov 2013 03:17:56 -0800 X-Google-Sender-Auth: LodEDk-nEqPYNMR49_7IMfW2_58 Message-ID: Subject: [RFC] how to get the size of a malloc(9) block ? From: Luigi Rizzo To: FreeBSD Current Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.16 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Nov 2013 11:17:59 -0000 in porting some linux kernel code to FreeBSD we stumbled upon ksize(), which returns the actual size of a kmalloc() block. We could easily implement it as the first part of realloc(9) -- see kern/kern_malloc.c Would it make sense to add this to the malloc(9) API ? The userspace equivalent seems to be malloc_usable_size(3) which according to the manpage appeared in FreeBSD 7.0 cheers luigi