Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #3539

Re: To standardize Boost.Pool

Date 2011-04-13 00:08 -0700
From Phil Bouchard <phil@fornux.com>
Newsgroups comp.lang.c++
Subject Re: To standardize Boost.Pool
References <4da38d4b@news.x-privat.org> <slrniq9ik7.gtj.grahn+nntp@frailea.sa.invalid> <4da4eede@news.x-privat.org>
Message-ID <4da54bdd$1@news.x-privat.org> (permalink)
Organization X-Privat.Org NNTP Server - http://www.x-privat.org

Show all headers | View raw


On 4/12/2011 5:31 PM, Phil Bouchard wrote:
> On 4/12/2011 2:56 PM, Jorgen Grahn wrote:
>>
>> What would those benefits be, according to you? Detecting bugs (e.g.
>> assert_on_heap(ptr)), or something else?
>
> Garbage collectors make use of such a function but also another memory
> manager I wrote called: Shifted Pointer where we can see a repetitive
> use of the function is_from() here:
> http://www.fornux.com/personal/philippe/devel/shifted_ptr/boost/shifted_ptr.hpp

After some discussion with Boost, contiguous memory pool objects could 
represent the process' stack, data and heap segments legally.  For example:

struct process
{
	static pool data;
	static pool heap;
	static pool stack;
};

The default implementation of the global operator ::new could be:

void * operator new(size_t n) { return process::heap.malloc(n); }


A call to is_from() with a pointer guaranteed to be within one of the 3 
pools will then be valid:

int * h = new int;
process::heap.is_from(h) // true
int s;
process::heap.is_from(& s) // false
process::stack.is_from(& s) // true
static int d;
process::heap.is_from(& d) // false
process::stack.is_from(& d) // false
process::data.is_from(& d) // true


Thanks,
-Phil

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

To standardize Boost.Pool  Phil Bouchard <phil@fornux.com> - 2011-04-12 07:44 -0600
  Re: To standardize Boost.Pool Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-04-12 21:56 +0000
    Re: To standardize Boost.Pool Phil Bouchard <phil@fornux.com> - 2011-04-12 17:31 -0700
      Re: To standardize Boost.Pool Phil Bouchard <phil@fornux.com> - 2011-04-13 00:08 -0700
        Re: To standardize Boost.Pool Öö Tiib <ootiib@hot.ee> - 2011-04-13 08:28 -0700
          Re: To standardize Boost.Pool Phil Bouchard <phil@fornux.com> - 2011-04-13 09:41 -0700
            Re: To standardize Boost.Pool Phil Bouchard <phil@fornux.com> - 2011-04-13 14:49 -0700
              Re: To standardize Boost.Pool Phil Bouchard <phil@fornux.com> - 2011-04-13 15:57 -0700
                Re: To standardize Boost.Pool Paavo Helde <myfirstname@osa.pri.ee> - 2011-04-13 23:39 -0500
                Re: To standardize Boost.Pool Phil Bouchard <phil@fornux.com> - 2011-04-13 22:43 -0700
                Re: To standardize Boost.Pool Phil Bouchard <phil@fornux.com> - 2011-04-13 22:53 -0700
                Re: To standardize Boost.Pool Miles Bader <miles@gnu.org> - 2011-04-14 15:55 +0900
                Re: To standardize Boost.Pool Phil Bouchard <phil@fornux.com> - 2011-04-14 00:15 -0700

csiph-web