This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: vector<> can probably never grow to it's maximum size!
On Tue, 2004-10-19 at 22:32, Dhruv Matani wrote:
> This patch seems more correct, because it handles the case where the
> memory in fact can be allocated.
Actually, thinking more on it, it seems that such a situation should
never arise in the first place, s please consider this patch canceled.
Paolo, your(and mine;-)) original patch seems fine to me. There were a 3
difference between our patches after all. I had 3 blank lines more
compared to yours :-)
>
> -Dhruv.
>
> On Tue, 2004-10-19 at 22:04, Dhruv Matani wrote:
> > On Tue, 2004-10-19 at 20:44, Paolo Carlini wrote:
> > > Dhruv Matani wrote:
> > >
> > > >And tries to explain more concretely what I'm trying to achieve and also
> > > >shows that it's do able in current C++.
> > > >
> > > Why you keep on refusing to deal with one issue at a time?
> >
> > I know :-( I have to try and consciously stick to one thing at a time,
> > and learn to control my frivolous nature.
> >
> > >
> > > The below cannot fix, not even in principle, the immediate problem that
> > > we have with __len overflowing size_type: all the new tricks in __mt_alloc
> > > are not in effect in this case, ::operator new for sure will never return
> > > an address == _M_start (half the memory is already used), it will always
> > > throw, even if you ask only for __old_size + 1.
> >
> > Ah! I did not think about this. You are right on this count because
> > vector first allocates and then deallocates, so no matter what if half
> > the memory is used, you are doomed.
> >
> > > Don't try to achieve the
> > > impossible, concentrate on the case of small memory allocations, managed
> > > via mt_alloc memory pools: in that case there is rooom for improvement..
> >
> > Yes, I have shown in the patch that the small size cases can be dealt
> > with quite well with __mt_alloc<>.
> >
> >
> > Attached is a patch and test-case which shows that the patch actually
> > works.
> >
> > >
> > > Paolo.
--
-Dhruv Matani.
http://www.geocities.com/dhruvbird/
The price of freedom is responsibility, but it's a bargain, because
freedom is priceless. ~ Hugh Downs