[GAP] unbounded strings package

Ted Baker baker at cs.fsu.edu
Thu Sep 22 17:33:07 CEST 2005


...oops!  Forget that qeuestion.
I answered my own question as soon as I looked a little
bit deeper into the implementation (after dumping the assembly code).

--Ted

On Thu, Sep 22, 2005 at 09:15:03AM -0400, Ted Baker wrote:
> In class, I used the package Ada.Strings.Unbounded as an example of
> how to use controlled types.  I ran into a surprise.  Am I blind, or
> does this leak storage?
> 
> S : Unbounded_String;
> ...
> S := S & 'c';
> 
> The Adjust procedure looks like this:
> 
> procedure Adjust (Object : in out Unbounded_String) is
> begin
>    --  Copy string, except we do not copy the statically allocated null
>    --  string, since it can never be deallocated.
>    if Object.Reference /= Null_String'Access then
>       Object.Reference := new String'(Object.Reference.all);
>    end if;
> end Adjust;
> 
> I was expecting that it would free the old reference before
> assigning the new one.
> 
> --Ted
> _______________________________________________
> GAP mailing list
> GAP at gnat.info
> /no-more-mailman.html
> To unsubscribe from this list, please contact the GAP GNAT Tracker administrator
> within your organization.


More information about the GAP mailing list