Boost logo

Boost :

Subject: Re: [boost] request for interest in a garbage collection library
From: Kasra (kasra_n500_at_[hidden])
Date: 2009-04-14 06:36:22


>> 3) gc pointers can point to middle of objects and arrays.

>I don't really understand how this works. Would the middle of an
>object/array get collected separately from the rest of it? That seems
>ridiculous, so I'm confused.

hi,

I think the following if what was ment:

base of array 'x'
|
v
[ 0 ][ 1 ][ 2 ][ 3 ][ 4 ] // an array of 5 elements
                 ^
                 |
                 pointer to 4-th element (ptr)

{c++} gc_free(ptr);

remove the entier object 'x' from memory so you don't have to
make sure you have a base pointer to 'x' to delete 'x'.

This comes handly for example when:

{c++[
  char* x = (char*)gc_malloc(5);
  char* end = x + 5;
  set_zero(x, 5);

  while(x != end && *x != 0) {
    // error, x should have been al zero
    gc_free(x); // note x doesn't point to base
    // of the allocated memory anymore!
  }

]}

With Best Regards

-- Kasra

      


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk