home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.amiga.programmer
- Path: sparky!uunet!gatech!concert!samba!usenet
- From: Todd_Lewis@unc.edu (Todd M. Lewis)
- Subject: Re: AmigaDOS library functions and ANSI-C programming
- Message-ID: <1992Dec30.142028.10351@samba.oit.unc.edu>
- Sender: usenet@samba.oit.unc.edu
- Nntp-Posting-Host: guitar.oit.unc.edu
- Organization: UNC Office of Information Technology
- References: <1hrqupINNipe@aurora.unice.fr>
- Date: Wed, 30 Dec 1992 14:20:28 GMT
- Lines: 37
-
- In article <1hrqupINNipe@aurora.unice.fr> beust@aurora.unice.fr (Cedric Beust)
- writes:
- >
- >In article <1992Dec29.221144.26405@urbana.mcd.mot.com>,
- >qbarnes@urbana.mcd.mot.com (Quentin Barnes) writes:
- >>AmigaDOS functions which take pointers to objects when the objects
- >>aren't modified are not marked as "const".
-
- >I was reading the autodoc for AddHead which looks like
- >AddHead(struct List *list, struct Node *node)
- >and I was wondering if a copy of the node would be done and then
- >pointed to in the list or if *my* node would be directly referenced.
-
- In this case, your node will be directly referenced and both
- *List and *node will be modified, so they should not be
- marked as "const". It never occurred to me that AddHead() might
- not use my node directly.
-
- >The advantage of this method? Simple : you can use the same
- >static node to create a list.
-
- The disadvantage? Lots of overhead for a feature you almost never
- need or want. In the rare case when you do, make the copies yourself
- before you call AddHead().
-
- >Since this wasn't mentioned in the autodoc,
- >I decided to go safe and allocate myself a new node at each call.
- >The information might be in the RKM (I didn't check), but I really
- >think this kind of detail should be mentioned, either in natural
- >language, or by the use of the const keyword whenever possible.
-
- In this case the const keyword would be dead wrong. However, it
- would be better if const were used where appropriate.
- --
- _/_/_/ _/ Todd_Lewis@unc.edu You can lead a horse to
- _/ _/ utoddl@guitar.oit.unc.edu Mohammad, but you can't make
- _/ _/_/_/ a mountain drink a mole hill.
-