how did SGI allocator handle pointer over range

Discussion in 'C++' started by hpsoar, Mar 10, 2009.

  1. hpsoar

    hpsoar Guest

    It seems that SGI allocator didn't take much measures to prevent
    pointer overange. Because I found that the chunk_alloc function
    returns a pointer that may point to the middle of a chunk of memory
    (the memory pool). Anyway, I think the most possible reason is that I
    didn't know enough about the allocator, for SGI STL is really a great
    STL. While If anyone can make some explanations, I'll be really
    gratefull.
     
    hpsoar, Mar 10, 2009
    #1
    1. Advertising

  2. hpsoar

    Bo Persson Guest

    hpsoar wrote:
    > It seems that SGI allocator didn't take much measures to prevent
    > pointer overange. Because I found that the chunk_alloc function
    > returns a pointer that may point to the middle of a chunk of memory
    > (the memory pool). Anyway, I think the most possible reason is that
    > I didn't know enough about the allocator, for SGI STL is really a
    > great STL. While If anyone can make some explanations, I'll be
    > really gratefull.


    I don't think this is the allocator's responsibility.

    Normally the allocator is a member of some container, and it is the
    container's responsibility to check (or not check) accesses to the
    storage it has allocated.

    For example, std::vector has an unchecked operator[] for member
    access, and an access function at() that verifies the index it is
    given.


    Bo Persson
     
    Bo Persson, Mar 10, 2009
    #2
    1. Advertising

  3. hpsoar

    James Kanze Guest

    On Mar 10, 6:14 pm, "Bo Persson" <> wrote:

    [...]
    > For example, std::vector has an unchecked operator[] for member
    > access, and an access function at() that verifies the index it is
    > given.


    Just a note: vector<>::eek:perator[] is NOT unchecked. A bounds
    error using operator[] is undefined behavior, so it is purely a
    quality of implementation issue---good implementations cause an
    assertion failure, or something similar (and bad implementations
    should be avoided, but you don't always have a choice).

    --
    James Kanze (GABI Software) email:
    Conseils en informatique orientée objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
     
    James Kanze, Mar 11, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?ISO-8859-1?Q?S=F6ren?=

    sgi rope experiences?

    =?ISO-8859-1?Q?S=F6ren?=, Jul 29, 2003, in forum: C++
    Replies:
    0
    Views:
    586
    =?ISO-8859-1?Q?S=F6ren?=
    Jul 29, 2003
  2. Chaman Singh

    SGI STL

    Chaman Singh, Apr 12, 2004, in forum: C++
    Replies:
    1
    Views:
    528
    Christopher Benson-Manica
    Apr 13, 2004
  3. hpsoar

    SGI allocator

    hpsoar, Mar 9, 2009, in forum: C++
    Replies:
    4
    Views:
    430
    James Kanze
    Mar 11, 2009
  4. hpsoar
    Replies:
    0
    Views:
    282
    hpsoar
    Mar 10, 2009
  5. Daniel Waite
    Replies:
    2
    Views:
    228
    Daniel Waite
    May 2, 2008
Loading...

Share This Page