comp.lang.ada
 help / color / mirror / Atom feed
From: Shark8 <onewingedshark@gmail.com>
Subject: Re: Interfaces.C.Strings chars_ptr memory management strategy
Date: Sat, 26 May 2018 06:56:03 -0700 (PDT)
Date: 2018-05-26T06:56:03-07:00	[thread overview]
Message-ID: <3f4f6e44-0d4c-4fb7-98df-b9c75ab18d68@googlegroups.com> (raw)
In-Reply-To: <ee2ce9f5-ffb1-4172-b291-09b66e0c1311@googlegroups.com>

On Saturday, May 26, 2018 at 6:45:01 AM UTC-6, NiGHTS wrote:
> On Friday, May 25, 2018 at 10:52:55 PM UTC-4, Shark8 wrote:
> > On Friday, May 25, 2018 at 4:22:13 PM UTC-6, NiGHTS wrote:
> > > 
> > > Here is just a quick and sloppy idea I had on how to tackle my problem.
> > > 
> > > str : chars_ptr := New_String ("                                     ");
> > > 
> > > I find the first line quite ugly. I'm sure there is an easier way to create a large empty string but I can't seem to come up with an elegant way to do it.
> > 
> > 
> > Something like this?
> > Big_String : chars_ptr := New_String( (1..200 => ' ') );
> 
> Thanks, It was on the tip of my brain I just for some reason couldn't put it together quite right.

It happens.
If you're going to be using this a lot I'd recommend a generic-wrapper something like:

GENERIC
  Max_Size : Natural;
FUNCTION Buffer_String Return Chars_Ptr;
FUNCTION Buffer_String Return Chars_Ptr IS
( New_String( (1..Max_Size => ' ') ) );

Or maybe a package.

  reply	other threads:[~2018-05-26 13:56 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-25 22:22 Interfaces.C.Strings chars_ptr memory management strategy NiGHTS
2018-05-26  2:52 ` Shark8
2018-05-26 12:44   ` NiGHTS
2018-05-26 13:56     ` Shark8 [this message]
2018-05-30 13:10 ` Alejandro R. Mosteo
2018-05-30 19:56   ` Randy Brukardt
2018-05-31 10:34     ` Alejandro R. Mosteo
2018-05-31 22:25       ` Randy Brukardt
2018-06-05 12:42         ` Alejandro R. Mosteo
2018-06-03 18:31 ` ytomino
2018-06-03 19:33   ` Dmitry A. Kazakov
2018-06-03 20:03     ` ytomino
2018-06-04  7:06       ` Dmitry A. Kazakov
2018-06-04  7:47         ` ytomino
2018-06-03 20:37     ` ytomino
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox