From owner-freebsd-current@FreeBSD.ORG Sat Nov 30 21:43:18 2013 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 212BACE9 for ; Sat, 30 Nov 2013 21:43:18 +0000 (UTC) Received: from plane.gmane.org (plane.gmane.org [80.91.229.3]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id CE8CF1BD4 for ; Sat, 30 Nov 2013 21:43:17 +0000 (UTC) Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1VmsJj-0001uM-6z for freebsd-current@freebsd.org; Sat, 30 Nov 2013 22:43:15 +0100 Received: from 79-139-19-75.prenet.pl ([79.139.19.75]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 30 Nov 2013 22:43:11 +0100 Received: from jb.1234abcd by 79-139-19-75.prenet.pl with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 30 Nov 2013 22:43:11 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: freebsd-current@freebsd.org From: jb Subject: Re: [RFC] how to get the size of a malloc(9) block ? Date: Sat, 30 Nov 2013 21:42:49 +0000 (UTC) Lines: 36 Message-ID: References: <52995C15.7010903@gmx.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: sea.gmane.org User-Agent: Loom/3.14 (http://gmane.org/) X-Loom-IP: 79.139.19.75 (Mozilla/5.0 (X11; Linux i686; rv:25.0) Gecko/20100101 Firefox/25.0) 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: Sat, 30 Nov 2013 21:43:18 -0000 gmx.com> writes: > ... > So new flags could be [1]: > - realloc_flags(p, s, REALLOCF_NO_MOVE): Resize object p, without moving > it, to size s. With this restriction, when requesting more memory, and > the specified amount isn't available, don't do anything (when requesting > less memory, always succeed). > - realloc_flags(p, s, REALLOCF_NO_MOVE | REALLOCF_ELASTIC): Resize object > p, without moving it, to size s. With this restriction, when requesting > more memory, and the specified amount isn't available, reserve as much as > possible (when requesting less memory, always succeed). > ... The realloc_flags(), having different behavior from realloc(), should state what happens if: If the pointer is a null pointer, the function does not change anything. If the new size is zero, the function does not change anything. If the new size is the same as the old size, the function does not change anything. The return values have to be reviewed also. The function returns: - a pointer to the object specifid on entry - a null pointer if the object could not be modified - a null pointer if there was insufficient free memory available to extend the size of the object Reference to realloc(): http://www.cplusplus.com/reference/cstdlib/realloc/ jb