From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,dbaf05888e191cb6 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-01-18 20:06:08 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!arclight.uoregon.edu!wn13feed!worldnet.att.net!bgtnsc04-news.ops.worldnet.att.net.POSTED!not-for-mail From: "David Thompson" Newsgroups: comp.lang.ada References: <5ad0dd8a.0301141717.2f1a9685@posting.google.com> <1l4V9.55183$Dn.10134@sccrnsc03> Subject: Re: Access to array slices? X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2615.200 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 Message-ID: Date: Sun, 19 Jan 2003 04:06:08 GMT NNTP-Posting-Host: 12.89.132.199 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc04-news.ops.worldnet.att.net 1042949168 12.89.132.199 (Sun, 19 Jan 2003 04:06:08 GMT) NNTP-Posting-Date: Sun, 19 Jan 2003 04:06:08 GMT Organization: AT&T Worldnet Xref: archiver1.google.com comp.lang.ada:33190 Date: 2003-01-19T04:06:08+00:00 List-Id: sk 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