From: "David Thompson" <david.thompson1@worldnet.att.net>
Subject: Re: Access to array slices?
Date: Sun, 19 Jan 2003 04:06:08 GMT
Date: 2003-01-19T04:06:08+00:00 [thread overview]
Message-ID: <QupW9.2397$zF6.190754@bgtnsc04-news.ops.worldnet.att.net> (raw)
In-Reply-To: mailman.1042648142.6683.comp.lang.ada@ada.eu.org
sk <sk@noname.com> wrote :
...
> An example of why I ask,
>
> int readlink(const char *path, char *buf, size_t bufsiz);
>
> Path => ICS.Chars_Ptr
>
> however
>
> Buf => access IC.Char_Array
>
> The choice seems dependent upon whether the imported
> function allocates or expects the caller to allocate.
>
Allocation has nothing to do with it; a C routine cannot
allocate unless it *returns* a pointer or receives a pointer
*to* a pointer (or receives a pointer to or returns a struct
*containing* a pointer, but that's much rarer).
The choice probably should be and at least here apparently is
dependent on whether the C code expects/requires a char pointer
to point to a C string, which is one or more char elements the last
of which and only the last is a null (terminator); or to "just" chars,
one or more, which can contain arbitrary data including nulls.
(readlink actually *could* have been designed and specified
to treat the target as a C string, since in practice it never
contains a null and its maximum size can be bounded,
but it wasn't, probably for consistency with other routines
like read and recv which cannot.)
--
- David.Thompson 1 now at worldnet.att.net
next prev parent reply other threads:[~2003-01-19 4:06 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-15 1:17 Access to array slices? Wojtek Narczynski
2003-01-15 3:13 ` tmoran
2003-01-15 16:31 ` sk
2003-01-15 20:48 ` tmoran
2003-01-16 1:00 ` sk
2003-01-16 1:43 ` tmoran
2003-01-19 4:06 ` David Thompson [this message]
2003-01-15 14:44 ` Steve
2003-01-16 2:18 ` Wojtek Narczynski
2003-01-16 3:52 ` tmoran
2003-01-17 18:04 ` Warren W. Gay VE3WWG
2003-01-15 15:06 ` Stephen Leake
2003-01-16 2:02 ` Wojtek Narczynski
2003-01-16 16:18 ` Stephen Leake
2003-01-16 16:48 ` Victor Porton
2003-01-19 4:32 ` sk
2003-01-27 2:59 ` David Thompson
2003-01-24 19:02 ` Wojtek Narczynski
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox