Re: Saving pointers to std::vector data

"Gary Setter" <[email protected]>
Newsgroups gmane.comp.gnu.aspell.devel
Message-ID <000001c5ad5d$fe8acc00$a3144a0c@pavilion>
----- Original Message ----- 
From: "Kevin Atkinson" <[email protected]>
To: "Gary Setter" <[email protected]>
Cc: <[email protected]>
Sent: Sunday, August 28, 2005 6:10 PM
Subject: Re: [aspell-devel] Saving pointers to std::vector data


> On Sat, 27 Aug 2005, Gary Setter wrote:
>
> > My recollection is that the addresses of object in standard
> > template library container object are not guaranteed to stay
> > valid. The
> > class is suppose to be able to reallocate memory as it needs
to.
> > Can anyone here back me up on this?
>
> For std::vector the address should remain valid as long as the
size of the
> object is not changed.  Gcc and possible also VC std:vector
never shrink
> so decreasing the size does not invalid address references into
an object.
> It could be the case the with BCB shrinking an object causes a
> reallocation.   Other objects (including the string class) do
not offer
> such a guarantee.
>
> > My plan is to continue looking into this and I may submit a
> > patch that eliminates the WordEntry intr field and replaces
it
> > with code that retrieves the data more directly. How I
continue
> > will be effected by your comments.
>
> Please submit a patch.  I may suggest an alternate solution but
I need to
> see your changes first.
>

Thanks Kevin,
I appreciate the explanation concerning the pointers becoming
corrupted.

One other thing that I noticed while playing with the suggest
module.
In Suggest::transfer(), we call check before adding a word to the
near_misses_final vector. This isn't the only place where late in
the process we call check before storing something away. Why is
that done? I would think that at that point a correction would be
have an acceptable spelling.

Best regards,
Gary
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.