home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / database / informix / 1867 < prev    next >
Encoding:
Internet Message Format  |  1992-09-02  |  2.5 KB

  1. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!wupost!emory!emory.mathcs.emory.edu
  2. From: widener!obelix.informix.com!johnl@emory.mathcs.emory.edu (Jonathan Leffler)
  3. Newsgroups: comp.databases.informix
  4. Subject: Re:  memory allocation under AIX 3.2
  5. Message-ID: <9451@emory.mathcs.emory.edu>
  6. Date: 3 Sep 92 01:48:37 GMT
  7. Sender: walt@mathcs.emory.edu
  8. Reply-To: widener!obelix.informix.com!johnl@emory.mathcs.emory.edu (Jonathan Leffler)
  9. Lines: 65
  10. X-Informix-List-ID: <list.1424>
  11.  
  12. }Date: Tue, 1 Sep 92 18:35:28 +0100
  13. }From: Manuel Monteiro <uunet!ssf.pt!mm>
  14. }Subject: memory allocation under AIX 3.2
  15. }X-Informix-List-Id: <list.1423>
  16. }
  17. }I had the following problem when upgrading from AIX 3.1 to AIX 3.2.
  18. }
  19. }In a esql/c program, when you pushquote((char *)str, strlen(str)),
  20. }what is really pushed into the stack is the pointer to the string, not
  21. }the contents of the string (I didn't know that 'call by reference' was
  22. }supported :-).
  23. }
  24. }With AIX 3.2 when you 'free' a block, previously allocated using
  25. }'malloc', its contents are destroyed. With AIX 3.1 its contents were
  26. }left undisturbed.
  27. }
  28. }I have several ec functions similar to
  29. }
  30. }f(fgl_pcnt)
  31. }     int fgl_pcnt;
  32. }{
  33. }  ...;
  34. }  char *x = malloc(...);        /* x size is not known in compile time */
  35. }
  36. }  ...;                          /* calculates x value */
  37. }
  38. }  /* RETURN x */
  39. }  pushquote(x, strlen(x));
  40. }  doretalloc(1);
  41. }  free( x );                    /* must free x space before returning */
  42. }  return(1);
  43. }}
  44. }
  45. }To be called from 4GL programs
  46. }
  47. }    CALL f() RETURNING str
  48. }
  49. }The problem is that the pointer pushed into the stack now points to a
  50. }'destroyed' block, no longer containing the values I want.
  51. }
  52. }Does anyone out there knows how to solve this problem (without
  53. }rewriting all those functions :-(?
  54. }Is there a port to AIX 3.2 that really copies the strings to the stack?
  55. }
  56. }BTW: I'm running INFORMIX-4GL Version 4.10.UD2 on a IBM RISC 6000/530
  57.  
  58. I wasn't sure I believed this diagnosis, but you're quite correct -- I
  59. cheated and looked at the source, and all the 4.1 stack routines do is copy
  60. the pointer onto the stack.  The obvious thing to point out is that it is
  61. only coincidence that the programs used to work at all; what if you had
  62. tried to assign two successive values to the same allocated space, as in:
  63.  
  64. s = malloc(space);
  65. strcpy(s, "something");
  66. pushquote(s, strlen(s));
  67. strcpy(s, "other string");
  68. pushquote(s, strlen(s));
  69. free(s);
  70. return(2);
  71.  
  72. I fear me that you are going to have modify your code.  I will raise this
  73. as an issue within Informix.
  74.  
  75. Yours,
  76. Jonathan Leffler (johnl@obelix.informix.com) #include <disclaimer.h>
  77.