Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!dayton!rosevax!sds!dave From: dave@sds.UUCP (dave schmidt x194) Newsgroups: comp.lang.c Subject: handles, pointers, etc Message-ID: <412@sds.UUCP> Date: Tue, 26-May-87 11:39:02 EDT Article-I.D.: sds.412 Posted: Tue May 26 11:39:02 1987 Date-Received: Sat, 30-May-87 05:17:08 EDT Organization: SciCom Data Services, Minnetonka, MN Lines: 26 >> To the "outside world", each object is known only by a handle, which is >> typically (here it comes, folks) a pointer to that malloc'ed struct. >> [...] >> Possibility #1: We cavalierly declare that no pointers are longer than >> char pointers: >Does the word "assume" ring a bell? From K&R, p. 210: "A pointer to one type may be converted to a pointer to another type. [...] It is guaranteed that a pointer to an object of a given size may be converted to a pointer to an object of a smaller size and back again without change." This means that all that is really assumed by "Possibility #1" is that a character is the smallest data object which can be pointed at (e.g., bit fields don't count). In fact, unless you have something quasi-strange like sizeof(char) == sizeof(short) or sizeof(char) == sizeof(int), this passage of K&R effectively guarantees that a character pointer is the "longest" data pointer possible. If you have something like sizeof(char) == sizeof(short), then all bets are off because K&R doesn't say "object of a smaller *or equal* size" and so a (short *) could be longer than a (char *) in this instance. In sum, there is an assumption being made by "Possibility #1", but it's a pretty safe one.