From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.acm.org>
Subject: Re: String declaration and initialization
Date: Thu, 22 May 2008 20:01:33 GMT
Date: 2008-05-22T20:01:33+00:00 [thread overview]
Message-ID: <xikZj.121208$TT4.24163@attbi_s22> (raw)
In-Reply-To: <g148oh$mcd$1@registered.motzarella.org>
S�bastien wrote:
>
> So I don't actually know how fast is the conversion between String and
> Unbounded_String but I think it's a waste of ressource.
You've already wasted quite a bit of your most expensive resource, a developer's
time, worrying about this. Far more efficient is to do it the obvious way, with
Unbounded_String, and only worry about the time of the conversions if you are
unable to meet your timing requirements.
> But you give me an Idea :
> declare
> buffer: access String;
> Free_String is new Unchecked_Deallocation(String, access all String);
> begin
> case SomeTest is
> case TEST1 =>
> buffer := new String("Test1");
> case TEST2 =>
> buffer := new String("Test2");
> end case;
> MyTreatment1(buffer.all, buffer.all'Size);
> MyTreatment2(buffer.all, buffer.all'Size);
> MyTreatment3(buffer.all, buffer.all'Size);
> end;
>
> but it doesn't work of course since I can't create with new an
> unconstrained object.
You can if you get the syntax right, as has been pointed out elsewhere. But this
is probably your worst choice. Here you have written a memory leak. You should
avoid explicit access values whenever possible, since such errors are so easy to
make.
--
Jeff Carter
"You a big nose have it."
Never Give a Sucker an Even Break
107
next prev parent reply other threads:[~2008-05-22 20:01 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-22 15:47 String declaration and initialization Sébastien
2008-05-22 16:05 ` Dmitry A. Kazakov
2008-05-22 16:47 ` Sébastien
2008-05-23 8:18 ` Dmitry A. Kazakov
2008-05-23 9:33 ` Sébastien
2008-05-22 16:16 ` Matthew Heaney
2008-05-22 16:58 ` Sébastien
2008-05-22 17:11 ` Robert A Duff
2008-05-22 18:16 ` Matthew Heaney
2008-05-22 20:01 ` Jeffrey R. Carter [this message]
2008-05-22 16:40 ` Jean-Pierre Rosen
2008-05-22 18:09 ` Martin Krischik
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox