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

[xml] xmlRead Memory



I have compiled a shared library in another application and I am using libxml2-2.6.30 library functions in the shared lib to help parse in-memory XML.
 
Following is the Makefile I used for compiling the shared lib:
 
=============================================
GCCLIBPATH=/usr/local/lib:/opt/ar/sdi/sonic_adapter/SonicCClient6.1-FCS/Solaris_GCC/bin/release
GCCPATH=/usr/local/bin/gcc
ARCHTYPE=SOLARIS_GCC
SMQROOT=/opt/ar/sdi/sonic_adapter/SonicCClient6.1-FCS/Solaris_GCC
BUILDMODE=release

# Compiler flags.
CC=gcc
CC=/usr/local/bin/gcc
CC=/usr/local/bin/sparc-sun-solaris2.8-gcc
CC=${GCCPATH}
LD=/usr/ccs/bin/ld
CFLAGS="-D_REENTRANT -L${GCCLIBPATH} -lnsl -lsmq -lstdc++ -lsocket -lrt  -lpthread -I/opt/ar/gemsdev/api/include -I/opt/ar/sdi/sonic_adapter/SonicCClient6.1-FCS/Solaris_GCC/include -Ilibxml -I/opt/ar/sdi/libxml2/libxml2-2.6.30/include"

LDFLAGS="-G"

CPPFLAGS="-I/tmp/TSO1 -I/usr/include"
LDLIBS="-lnsl -lw -lpthread -lxml2"


$CC $CPPFLAGS $CFLAGS -DUNIX -D$ARCHTYPE -I$SMQROOT/include -L$SMQROOT/bin/$BUILDMODE $LDLIBS $LDFLAGS -o $1.so $1.c
exit
============================================

The shared lib is loaded as a multithreaded plugin in a daemon on Solaris 10.

The problem is that when the code in the attached file runs for the second time it crashes at line 44. The first run has no problems.

Any pointers? Please help.

Thanks in advance,

Arthur

  //Allocate mem for valueOperandPtr->u.value.u.charVal - 
  //which holds an XML string to be sent out to the external service
  sdiRequest=(char *)malloc(strlen(valueOperandPtr->u.value.u.charVal)+1);

  /* NOTE : Had to add "<" in front of the XML value
  sent in from the form as the value of the search since Remedy
  strips the leading <. Most likely thinking it was an operator*/
  sprintf(sdiRequest,"<%s",valueOperandPtr->u.value.u.charVal);

  len=strlen(sdiRequest);
  sdiRequestDoc = xmlReadMemory(sdiRequest, len, "noname0.xml", NULL, 0);
  if (doc == NULL)
    {
      free(sdiRequest);
      return AddErrorMessage(status, AR_RETURN_ERROR,
                             PLUGIN_ERROR_GENERIC,
                             "Request sent in is not a well formed XML");
    }

  Request();
  iInitRun=0;
  sdiRequest=talker(sdiRequest);
  Release();
  ARPluginLogging(AR_PLUGIN_LOG_INFO, "Eval");

  if (sdiRequest == NULL)
    {
      free(sdiRequest);
      return AddErrorMessage(status, AR_RETURN_ERROR,
                             PLUGIN_ERROR_GENERIC,
                             "No Output from SDI");
    }


  /*
   * The document being in memory, it has no base per RFC 2396,
   * and the argument - "noname.xml" will serve as its base.
   */
  len = strlen(sdiRequest);
  xmlFreeDoc(sdiRequestDoc);
  
  ARPluginLogging(AR_PLUGIN_LOG_INFO,
                                      "After len - %d\n",len);
  doc = xmlReadMemory(sdiRequest, len, "noname1.xml", NULL, 0);
  ARPluginLogging(AR_PLUGIN_LOG_INFO,
                                      "After doc\n");


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