comp.lang.ada
 help / color / mirror / Atom feed
From: Victor Porton <porton@narod.ru>
Subject: Allocating a C string without heap
Date: Sat, 26 Jul 2014 19:01:20 +0300
Date: 2014-07-26T19:01:20+03:00	[thread overview]
Message-ID: <lr0jcd$je3$1@speranza.aioe.org> (raw)

Let we have an Ada String.

I need to pass it converted to a C string into a C library function.

Now I do it with Interfaces.C.Strings.New_String. But it is slow as it uses 
the heap and requires (not to forget incidentally!) further 
Interfaces.C.Strings.Free.

Is there a better way to do this? I mean that we would probably create a 
nul-terminated char_array (not on the heap but on the stack!) and pass the 
pointer to its first element.

This would be both safer an faster.

Can you elaborate on this?

-- 
Victor Porton - http://portonvictor.org

             reply	other threads:[~2014-07-26 16:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-26 16:01 Victor Porton [this message]
2014-07-26 16:20 ` Allocating a C string without heap Dmitry A. Kazakov
2014-07-26 16:30   ` Victor Porton
2014-07-26 18:38     ` Dmitry A. Kazakov
replies disabled

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