Changeset 63


Ignore:
Timestamp:
Jan 8, 2011, 1:01:25 AM (13 years ago)
Author:
djay
Message:

Remove memory leaks. Add support for minOccurs and maxOccurs informations in the inputs maps to close ticket #12.

Location:
trunk/zoo-kernel
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/zoo-kernel/service_internal.c

    r59 r63  
    11601160    maps* mcursor=outputs;
    11611161    elements* scursor=serv->outputs;
    1162     while(mcursor!=NULL && scursor!=NULL){
     1162    while(mcursor!=NULL){
    11631163      printIOType(doc,nc,ns,ns_ows,scursor,mcursor,"Output");
    11641164      mcursor=mcursor->next;
    1165       scursor=scursor->next;
    11661165    }
    11671166    xmlAddChild(n,nc);
     
    15331532            toto=createMap("extension","txt");
    15341533        }
    1535         if(toto==NULL)
     1534        else
    15361535          toto=createMap("extension","txt");
    15371536        hasExt=false;
     
    16491648}
    16501649
    1651 char* addDefaultValues(maps** out,elements* in,maps* m,char* type){
     1650char* addDefaultValues(maps** out,elements* in,maps* m,int type){
    16521651  elements* tmpInputs=in;
    16531652  maps* out1=*out;
     
    16551654    maps *tmpMaps=getMaps(out1,tmpInputs->name);
    16561655    if(tmpMaps==NULL){
    1657       map* tmpMap1=getMap(tmpInputs->content,"minOccurs");
    1658       if(strncmp(type,"inputs",6)==0)
    1659         if(tmpMap1!=NULL && atoi(tmpMap1->value)>=1){
    1660           return tmpInputs->name;
    1661         }
    16621656      maps* tmpMaps2=(maps*)malloc(MAPS_SIZE);
    16631657      tmpMaps2->name=strdup(tmpInputs->name);
    16641658      tmpMaps2->content=NULL;
    16651659      tmpMaps2->next=NULL;
     1660     
     1661      if(type==0){
     1662        map* tmpMapMinO=getMap(tmpInputs->content,"minOccurs");
     1663        if(tmpMapMinO!=NULL)
     1664          if(atoi(tmpMapMinO->value)>=1){
     1665            freeMaps(&tmpMaps2);
     1666            free(tmpMaps2);
     1667            return tmpInputs->name;
     1668          }
     1669          else{
     1670            if(tmpMaps2->content==NULL)
     1671              tmpMaps2->content=createMap("minOccurs",tmpMapMinO->value);
     1672            else
     1673              addToMap(tmpMaps2->content,"minOccurs",tmpMapMinO->value);
     1674          }
     1675        map* tmpMaxO=getMap(tmpInputs->content,"maxOccurs");
     1676        if(tmpMaxO!=NULL)
     1677          if(tmpMaps2->content==NULL)
     1678            tmpMaps2->content=createMap("maxOccurs",tmpMaxO->value);
     1679          else
     1680            addToMap(tmpMaps2->content,"maxOccurs",tmpMaxO->value);
     1681      }
     1682
    16661683      iotype* tmpIoType=tmpInputs->defaults;
    1667       while(tmpIoType!=NULL){
    1668         addMapToMap(&tmpMaps2->content,tmpIoType->content);
    1669         tmpIoType=tmpIoType->next;
    1670       }
    1671       if(strncmp(type,"outputs",7)==0){
     1684      if(tmpIoType!=NULL){
     1685        map* tmpm=tmpIoType->content;
     1686        while(tmpm!=NULL){
     1687          if(tmpMaps2->content==NULL)
     1688            tmpMaps2->content=createMap(tmpm->name,tmpm->value);
     1689          else
     1690            addToMap(tmpMaps2->content,tmpm->name,tmpm->value);
     1691          tmpm=tmpm->next;
     1692        }
     1693      }
     1694      if(type==1){
    16721695        map *tmpMap=getMap(tmpMaps2->content,"value");
    16731696        if(tmpMap==NULL)
     
    16761699      if(out1==NULL){
    16771700        *out=dupMaps(&tmpMaps2);
     1701        out1=*out;
    16781702      }
    16791703      else
    16801704        addMapsToMaps(&out1,tmpMaps2);
     1705      freeMap(&tmpMaps2->content);
     1706      free(tmpMaps2->content);
     1707      tmpMaps2->content=NULL;
    16811708      freeMaps(&tmpMaps2);
    16821709      free(tmpMaps2);
     
    16861713      iotype* tmpIoType=getIoTypeFromElement(tmpInputs,tmpInputs->name,
    16871714                                             tmpMaps->content);
     1715
     1716      if(type==0) {
     1717        map* tmpMap1=getMap(tmpInputs->content,"minOccurs");
     1718        if(tmpMap1!=NULL){
     1719          if(tmpMaps->content==NULL)
     1720            tmpMaps->content=createMap("minOccurs",tmpMap1->value);
     1721          else
     1722            addToMap(tmpMaps->content,"minOccurs",tmpMap1->value);
     1723        }
     1724        map* tmpMaxO=getMap(tmpInputs->content,"maxOccurs");
     1725        if(tmpMaxO!=NULL){
     1726          if(tmpMaps->content==NULL)
     1727            tmpMaps->content=createMap("maxOccurs",tmpMap1->value);
     1728          else
     1729            addToMap(tmpMaps->content,"maxOccurs",tmpMap1->value);
     1730        }
     1731      }
     1732
    16881733      if(tmpIoType!=NULL){
    16891734        map* tmpContent=tmpIoType->content;
     
    16951740            fprintf(stderr,"addDefaultValues %s => %s\n",tmpContent->name,tmpContent->value);
    16961741#endif
    1697               if(tmpMaps->content==NULL)
    1698                 tmpMaps->content=createMap(tmpContent->name,tmpContent->value);
    1699               else
    1700                 addToMap(tmpMaps->content,tmpContent->name,tmpContent->value);
     1742            if(tmpMaps->content==NULL)
     1743              tmpMaps->content=createMap(tmpContent->name,tmpContent->value);
     1744            else
     1745              addToMap(tmpMaps->content,tmpContent->name,tmpContent->value);
    17011746          }
    17021747          tmpContent=tmpContent->next;
  • trunk/zoo-kernel/service_internal.h

    r34 r63  
    104104  char *base64(const unsigned char*,int);
    105105
    106   char* addDefaultValues(maps**,elements*,maps*,char*);
     106  char* addDefaultValues(maps**,elements*,maps*,int);
    107107
    108108  /*defined in zoo_loader.c*/
  • trunk/zoo-kernel/service_internal_python.c

    r61 r63  
    3434  tmp=getMapFromMaps(*main_conf,"env","PYTHONPATH");
    3535  char *python_path;
     36#ifdef DEBUG
    3637  fprintf(stderr,"PYTHON SUPPORT \n");
     38#endif
    3739  fflush(stderr);
    3840  if(tmp!=NULL){
     41#ifdef DEBUG
    3942    fprintf(stderr,"PYTHON SUPPORT (%i)\n",strlen(tmp->value));
     43#endif
    4044    python_path=(char*)malloc((strlen(tmp->value))*sizeof(char));
    4145    sprintf(python_path,"%s",tmp->value);
  • trunk/zoo-kernel/zoo_service_loader.c

    r60 r63  
    2727extern "C" int yylex();
    2828extern "C" int crlex();
    29 
    3029
    3130extern "C" {
     
    472471    SERVICE_URL=strdup(tmpm->value);
    473472  else
    474     SERVICE_URL=DEFAULT_SERVICE_URL;
     473    SERVICE_URL=strdup(DEFAULT_SERVICE_URL);
    475474
    476475  service* s[100];
     
    16141613   * DataInputs and ResponseDocument / RawDataOutput
    16151614   */ 
    1616   char *dfv=addDefaultValues(&request_input_real_format,s1->inputs,m,"inputs");
     1615  char *dfv=addDefaultValues(&request_input_real_format,s1->inputs,m,0);
    16171616  if(strcmp(dfv,"")!=0){
    16181617    char tmps[1024];
     
    16211620    addToMap(tmpe,"code","MissingParameterValue");
    16221621    printExceptionReportResponse(m,tmpe);
     1622    freeService(&s1);
     1623    free(s1);
    16231624    freeMap(&tmpe);
    16241625    free(tmpe);
     
    16261627    free(m);
    16271628    free(REQUEST);
     1629    free(SERVICE_URL);
    16281630    freeMaps(&request_input_real_format);
    16291631    free(request_input_real_format);
     
    16341636    return 1;
    16351637  }
    1636   addDefaultValues(&request_output_real_format,s1->outputs,m,"outputs");
     1638  addDefaultValues(&request_output_real_format,s1->outputs,m,1);
    16371639
    16381640#ifdef DEBUG
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png