[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [xmlblaster] Solaris C build changes



Joshi, Mehul wrote:
FYI:

Just some notes in case someone else runs into the same issues compiling C
libs on solaris.
Please feel free to comment perhaps there are is a better way to do this...

OS:
SunOS fuj01 5.8 Generic_117350-05 sun4us sparc FJSV,GPUZC-M
$run command
$./build -verbose -Duse-CC=true  c
..this caused 2 errors in XmlBlasterUnmanaged.c file. They both seem to be
casting errors.
I have fixed these as follows:

============================================================================
===================
75
76 Dll_Export XmlBlasterAccessUnparsed
*getXmlBlasterAccessUnparsedUnmanaged(int argc, const char* const* argv){
77 /** argv seems to be freed by C#, so we clone it here */
78 int j,i=0; /* Changed line */
79 char ** ptr; 80 j = sizeof(char *); /*New line*/
81 ptr = (char **) malloc(argc * j); /* Changed line */
Hmm, why do we need to introduce the temporary variable 'j'?
What was the compiler error reported? Does it complain about the 'const' which you have removed or does it complain about the
malloc(argc*sizeof(char *))?


On my Solaris it doesn't complain.

Does this work?
  int i=0;
  const char ** ptr = (const char **)malloc(argc*sizeof(char *));
  for (i=0; i<argc; ++i) {

82 for (i=0; i<argc; ++i) {
83 ptr[i] = strcpyAlloc(argv[i]);
84 }
85 return getXmlBlasterAccessUnparsed(argc, ptr);
86 }
"/xta/joshim/mom/xmlBlaster/build.tmp/src/c/socket/XmlBlasterUnmanaged.c"
[Modified] line 47 of 252 --18%-- ============================================================================
===================



248 Dll_Export const char *xmlBlasterUnmanagedUsage() {
249 char *usage = (char
*)malloc(XMLBLASTER_MAX_USAGE_LEN*sizeof(char)); /* changed line*/
250 return xmlBlasterAccessUnparsedUsage(usage);
251 }
This cast was already fixed directly after the release of 1.3 (see current svn),

thanks for reporting

Marcel
   252

============================================================================
===================