Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > how did SGI allocator handle pointer over range

Reply
Thread Tools

how did SGI allocator handle pointer over range

 
 
hpsoar
Guest
Posts: n/a
 
      03-10-2009
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.
 
Reply With Quote
 
 
 
 
Bo Persson
Guest
Posts: n/a
 
      03-10-2009
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


 
Reply With Quote
 
 
 
 
James Kanze
Guest
Posts: n/a
 
      03-11-2009
On Mar 10, 6:14 pm, "Bo Persson" <(E-Mail Removed)> 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<>: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:(E-Mail Removed)
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
SGI allocator hpsoar C++ 4 03-11-2009 09:55 AM
another question about SGI allocator hpsoar C++ 0 03-10-2009 12:59 PM
VOIP over VPN over TCP over WAP over 3G Theo Markettos UK VOIP 2 02-14-2008 03:27 PM
Compile linux, aix4, sgi, or sun on Mac OS X? Bill Mazlar Computer Support 22 09-23-2004 04:39 AM



Advertisments