From owner-freebsd-arch@FreeBSD.ORG Tue Mar 28 06:07:16 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 A420016A41F; Tue, 28 Mar 2006 06:07:16 +0000 (UTC) (envelope-from vd@datamax.bg) Received: from jengal.datamax.bg (jengal.datamax.bg [82.103.104.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2A0D043D48; Tue, 28 Mar 2006 06:07:16 +0000 (GMT) (envelope-from vd@datamax.bg) Received: from qlovarnika.bg.datamax (qlovarnika.bg.datamax [192.168.10.2]) by jengal.datamax.bg (Postfix) with SMTP id E685BB857; Tue, 28 Mar 2006 09:07:14 +0300 (EEST) Received: (nullmailer pid 97643 invoked by uid 1002); Tue, 28 Mar 2006 06:07:14 -0000 Date: Tue, 28 Mar 2006 09:07:14 +0300 From: Vasil Dimov To: John Baldwin Message-ID: <20060328060714.GB97222@qlovarnika.bg.datamax> References: <44247DF1.8000002@FreeBSD.org> <200603271110.02917.jhb@freebsd.org> <44281421.3060401@FreeBSD.org> <200603271520.11381.jhb@freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="GID0FwUMdk1T2AWN" Content-Disposition: inline In-Reply-To: <200603271520.11381.jhb@freebsd.org> X-OS: FreeBSD 6.0-STABLE User-Agent: Mutt/1.5.11 Cc: Robert Watson , 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 Reply-To: vd@FreeBSD.org List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Mar 2006 06:07:16 -0000 --GID0FwUMdk1T2AWN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Mar 27, 2006 at 03:20:08PM -0500, John Baldwin wrote: > On Monday 27 March 2006 11:34, Jason Evans wrote: [...] > > 4) Porting code from Linux. Case in point: Xara Xtreme, currently bein= g=20 > > ported by Vasil Dimov. At the moment, he has to use dlmalloc. >=20 > Does it contain a G/C of its own or some such? >=20 Here is what malloc_usable_size() is used for in Xara Xtreme: * They keep track of how much (heap) memory is available. Maybe they support an option like "do not use more that N MiB". This is achieved by a wrappers to realloc() and free() which manipulate a global? variable AvailableRAM - the realloc() wrapper decreases AvailableRAM with (newsize - oldsize) where oldsize is retrieved with malloc_usable_size(). The free() wrapper increases AvailableRAM with what is returned by malloc_usable_size(). * Debugging purposes like keeping track of how much memory they allocated, the filename and linenumber of the allocation * They use a function similar to realloc(), but which receives the number of bytes they need to increment the buffer with, rather than the new size, so they call realloc(p,increment+malloc_usable_size(p)) * A lot of other miscellaneous purposes where they should really keep track of how many bytes they requested from malloc() rather than calling malloc_usable_size(). --=20 Vasil Dimov gro.DSBeerF@dv Testing can show the presence of bugs, but not their absence. -- Edsger W. Dijkstra --GID0FwUMdk1T2AWN Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- iD8DBQFEKNKSFw6SP/bBpCARApOSAJ91DRTph0Jb5ynCUDFnT8Yx+e8gogCeNcuS nQCPJsUyC/K/Mi6EbEkvyH0= =VfHa -----END PGP SIGNATURE----- --GID0FwUMdk1T2AWN--