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-26 18:59:26 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!wn11feed!wn13feed!wn12feed!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> 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: Mon, 27 Jan 2003 02:59:25 GMT NNTP-Posting-Host: 12.89.166.210 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc04-news.ops.worldnet.att.net 1043636365 12.89.166.210 (Mon, 27 Jan 2003 02:59:25 GMT) NNTP-Posting-Date: Mon, 27 Jan 2003 02:59:25 GMT Organization: AT&T Worldnet Xref: archiver1.google.com comp.lang.ada:33441 Date: 2003-01-27T02:59:25+00:00 List-Id: sk wrote : > tmoran@acm.org > > it will usually have "chars **buf" or "Handle *h" where ... > > A handy rule of thumb which I hope to remember (I think that > "Handle *h" is largely a MS/Window thing isn't it ?). > MSWindows certainly uses handles extensively, but they are far from the only people to do so. MacOS did; I believe X did; I've used lots of other libraries/packages which each have their own (collection of) handle types. It's a generic and widely useful concept, or if you like pattern. > david.thompson1@worldnet.att.net > > 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). > > I seem to recall that some of the Window C routines allocated > some of the data structures internally and passed a (or updated > a passed in) pointer back to the caller ? > You can't "update a pointer passed in" in C; more generally, no called routine can ever update a caller's actual argument, only the value pointed to by a pointer argument and/or provide a return value (which may be stored, or discarded, by the caller). Another thing you can do (in general) is *not* give out actual pointers; instead a called library maintains its own private storage, possibly with dynamic/heap allocation and pointers and possibly not, and gives out only numbers or other (private) values that identify things within that private storage; these go by a variety of names often including "number" or "index" or "capability" e.g. a color index in a palette. I don't know of MSWindows using these but I haven't looked hard. In C of course this means e.g. return an int, or take a pointer to int. -- - David.Thompson 1 now at worldnet.att.net