home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / sys / amiga / programm / 17945 < prev    next >
Encoding:
Internet Message Format  |  1992-12-30  |  2.5 KB

  1. Path: sparky!uunet!gatech!rpi!ghost.dsi.unimi.it!univ-lyon1.fr!taloa.unice.fr!beust
  2. From: beust@aurora.unice.fr (Cedric Beust)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: AmigaDOS library functions and ANSI-C programming
  5. Date: 30 Dec 1992 10:42:49 +0100
  6. Organization: University of Nice Sophia-Antipolis, France
  7. Lines: 52
  8. Distribution: world
  9. Message-ID: <1hrqupINNipe@aurora.unice.fr>
  10. References: <1992Dec29.221144.26405@urbana.mcd.mot.com>
  11. NNTP-Posting-Host: aurora.unice.fr
  12.  
  13.  
  14. In article <1992Dec29.221144.26405@urbana.mcd.mot.com>,
  15. qbarnes@urbana.mcd.mot.com (Quentin Barnes) writes:
  16.  
  17. >I ran across a widespread problem with the AmigaDOS specific
  18. >prototypes/libraries with writing ANSI-C code.  AmigaDOS
  19. >functions which take pointers to objects when the objects
  20. >aren't modified are not marked as "const". 
  21. >
  22. > [short example deleted]
  23. >
  24. >I don't care about hacks such as marking those errors ignored
  25. >or casting.  The real problem is that the AmigaDOS library
  26. >function calls need their signatures cleaned up.  This may be
  27. >an annoying problem with ANSI-C code, but it will prove fatal
  28. >with C++.
  29.  
  30.     Funny, I had the very same thought yesterday night! (no, I wasn't
  31.     dreaming of Amiga programming, don't worry for my mental health :-)).
  32.  
  33.     I was reading the autodoc for AddHead which looks like
  34.     AddHead(struct List *list, struct Node *node)
  35.     and I was wondering if a copy of the node would be done and then
  36.     pointed to in the list or if *my* node would be directly referenced.
  37.  
  38.     This is a major difference! The safest way in my mind is when
  39.     the system takes care of allocating a new node, copying the one
  40.     I pass and then referencing this one, leaving me free to to what
  41.     I will with my node (I used this scheme in my generic database
  42.     package which I described shortly in a previous post).
  43.  
  44.     The advantage of this method? Simple : you can use the same
  45.     static node to create a list. For example :
  46.  
  47. static struct Node *myNode;
  48.  
  49. while (condition) {
  50.   /* fill myNode with some value */
  51.   AddHead(list, myNode);
  52. }
  53.  
  54.     There might be drawbacks of course but this is not my point (sorry,
  55.     I digressed a little). Since this wasn't mentioned in the autodoc,
  56.     I decided to go safe and allocate myself a new node at each call.
  57.     The information might be in the RKM (I didn't check), but I really
  58.     think this kind of detail should be mentioned, either in natural
  59.     language, or by the use of the const keyword whenever possible.
  60.  
  61.     Just a few thoughts...
  62. --
  63. Cedric BEUST, beust@sa.inria.fr, Bull Research Koala proj, KoalaBus & xforum
  64. Pho:(33) 93.65.78.07(.66 Fax), INRIA, B.P.93 - 06902 Sophia Antipolis, FRANCE.
  65.