Ignore:
Timestamp:
May 10, 2014, 4:23:03 PM (10 years ago)
Author:
djay
Message:

Remove leaks from DescribeProcess? and JavaScript? support. Fix wrong ulinet update on previous commit. Use the new updateStatus/setOutputValue functions as described in #88 from longProcess. Add default value for QREncode service in ZCFG. Fix name of profile service in the ZCFG file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/zoo-project/zoo-kernel/service_internal_js.c

    r453 r471  
    3939  for(i=0;i<argc;i++){
    4040    JSString* jsmsg = JS_ValueToString(cx,argv[i]);
    41     fprintf(stderr,"[ZOO-API:JS] %s\n",JS_EncodeString(cx,jsmsg));
     41    char *tmp=JS_EncodeString(cx,jsmsg);
     42    fprintf(stderr,"[ZOO-API:JS] %s\n",tmp);
     43    free(tmp);
    4244  }
    4345  JS_MaybeGC(cx);
     
    6971#endif
    7072    JSObject *api_script1=loadZooApiFile(cx,JS_GetGlobalObject(cx),api0);
     73    free(api0);
    7174  }
    7275  JS_MaybeGC(cx);
     
    158161#endif
    159162  JSObject *api_script1=loadZooApiFile(cx,global,api0);
     163  free(api0);
    160164  fflush(stderr);
    161165
     
    166170#endif
    167171  JSObject *api_script2=loadZooApiFile(cx,global,api1);
     172  free(api1);
    168173  fflush(stderr);
    169174
     
    183188  struct stat file_status;
    184189  stat(filename, &file_status);
    185   char *source=(char*)malloc(file_status.st_size);
     190  //char *source=(char*)malloc(file_status.st_size);
    186191  uint16 lineno;
    187192  jsval rval;
     
    194199    char tmp1[1024];
    195200    sprintf(tmp1,"Unable to load JavaScript file %s",filename);
     201    free(filename);
    196202    map* err=createMap("text",tmp1);
    197     addMapToMap(&err,createMap("code","NoApplicableCode"));
     203    addToMap(err,"code","NoApplicableCode");
    198204    printExceptionReportResponse(mc,err);
     205    freeMap(&err);
     206    free(err);
     207    JS_MaybeGC(cx);
    199208    JS_DestroyContext(cx);
    200209    JS_DestroyRuntime(rt);
    201210    JS_ShutDown();
    202     exit(-1);
    203   }
     211    return -1;
     212  }
     213 
    204214
    205215  /* Call a function in obj's scope. */
     
    243253    freeMap(&err);
    244254    free(err);
     255    free(filename);
     256    JS_MaybeGC(cx);
    245257    JS_DestroyContext(cx);
    246258    JS_DestroyRuntime(rt);
    247259    JS_ShutDown();
    248260    // Should return -1 here but the unallocation won't work from zoo_service_loader.c line 1847
    249     exit(-1);
     261    return -1;
    250262  }
    251263
     
    344356  JS_DestroyRuntime(rt);
    345357  JS_ShutDown();
     358  free(filename);
    346359#ifdef JS_DEBUG
    347360  fprintf(stderr,"Returned value %d\n",res);
     
    481494        jsmsg = JS_ValueToString(cx,vp);
    482495        len1 = JS_GetStringLength(jsmsg);
    483 
     496       
     497        tmp=JS_EncodeString(cx,jsmsg);
    484498        tres=(maps*)malloc(MAPS_SIZE);
    485         tres->name=zStrdup(JS_EncodeString(cx,jsmsg));
     499        tres->name=zStrdup(tmp);
    486500        tres->content=NULL;
    487501        tres->next=NULL;
    488502
    489503        jsval nvp=JSVAL_NULL;
    490         if((JS_GetProperty(cx, tt, JS_EncodeString(cx,jsmsg), &nvp)==JS_FALSE)){
    491 #ifdef JS_DEBUG
    492           fprintf(stderr,"Enumerate id : %d => %s => No more value\n",oi,JS_EncodeString(cx,jsmsg));
     504        if((JS_GetProperty(cx, tt, tmp, &nvp)==JS_FALSE)){
     505#ifdef JS_DEBUG
     506          fprintf(stderr,"Enumerate id : %d => %s => No more value\n",oi,tmp);
    493507#endif
    494508        }
    495        
     509        free(tmp);
    496510        JSObject *nvp1=JSVAL_TO_OBJECT(JSVAL_NULL);
    497511        JS_ValueToObject(cx,nvp,&nvp1);
     
    510524               
    511525      }
     526      JS_DestroyIdArray(cx,idp);
    512527    }
    513528  }
     
    550565        jsmsg = JS_ValueToString(cx,vp);
    551566        len1 = JS_GetStringLength(jsmsg);
    552 #ifdef JS_DEBUG
    553         fprintf(stderr,"Enumerate id : %d => %s\n",oi,JS_EncodeString(cx,jsmsg));
     567        tmp=JS_EncodeString(cx,jsmsg);
     568#ifdef JS_DEBUG
     569        fprintf(stderr,"Enumerate id : %d => %s\n",oi,tmp);
    554570#endif
    555571        jsval nvp=JSVAL_NULL;
    556         if((JS_GetProperty(cx, JSVAL_TO_OBJECT(tmp1), JS_EncodeString(cx,jsmsg), &nvp)==JS_FALSE)){
    557 #ifdef JS_DEBUG
    558           fprintf(stderr,"Enumerate id : %d => %s => No more value\n",oi,JS_EncodeString(cx,jsmsg));
     572        if((JS_GetProperty(cx, JSVAL_TO_OBJECT(tmp1), tmp, &nvp)==JS_FALSE)){
     573#ifdef JS_DEBUG
     574          fprintf(stderr,"Enumerate id : %d => %s => No more value\n",oi,tmp);
    559575#endif
    560576        }
    561        
     577        free(tmp);
    562578        if(JSVAL_IS_OBJECT(nvp)){
    563579#ifdef JS_DEBUG
     
    571587        if(JSVAL_IS_OBJECT(nvp1j)){
    572588          JSString *jsmsg1;
     589          char *tmp1, *tmp2;
    573590          JSObject *nvp2=JSVAL_TO_OBJECT(JSVAL_NULL);
    574591          jsmsg1 = JS_ValueToString(cx,nvp1j);
    575592          len1 = JS_GetStringLength(jsmsg1);
    576 #ifdef JS_DEBUG
    577           fprintf(stderr,"JSVAL NVP1J IS OBJECT %s = %s\n",JS_EncodeString(cx,jsmsg),JS_EncodeString(cx,jsmsg1));
    578 #endif
    579           if(strcasecmp(JS_EncodeString(cx,jsmsg1),"[object Object]")==0){
    580             tres->name=zStrdup(JS_EncodeString(cx,jsmsg));
     593          tmp1=JS_EncodeString(cx,jsmsg1);
     594          tmp2=JS_EncodeString(cx,jsmsg);
     595#ifdef JS_DEBUG
     596          fprintf(stderr,"JSVAL NVP1J IS OBJECT %s = %s\n",JS_EncodeString(cx,jsmsg),tmp1);
     597#endif
     598          if(strcasecmp(tmp1,"[object Object]")==0){
     599            tres->name=zStrdup(tmp2);
    581600            tres->content=mapFromJSObject(cx,nvp1j);
    582601          }
    583602          else
    584             if(strcasecmp(JS_EncodeString(cx,jsmsg),"name")==0){
    585               tres->name=zStrdup(JS_EncodeString(cx,jsmsg1));
     603            if(strcasecmp(tmp2,"name")==0){
     604              tres->name=zStrdup(tmp1);
    586605            }
    587606            else{
    588607              if(tres->content==NULL)
    589                 tres->content=createMap(JS_EncodeString(cx,jsmsg),JS_EncodeString(cx,jsmsg1));
     608                tres->content=createMap(tmp2,tmp1);
    590609              else
    591                 addToMap(tres->content,JS_EncodeString(cx,jsmsg),JS_EncodeString(cx,jsmsg1));
     610                addToMap(tres->content,tmp2,tmp1);
    592611            }
     612          free(tmp1);
     613          free(tmp2);
    593614        }
    594615#ifdef JS_DEBUG
     
    607628      free(tres);
    608629      tres=NULL;
    609 
     630      JS_DestroyIdArray(cx,idp);
    610631    }
    611632  }
     
    633654      JSString* str;
    634655      JS_IdToValue(cx,id,&vp);
    635       char *c, *tmp;
     656      char *c, *tmp, *tmp1;
    636657      JSString *jsmsg,*jsmsg1;
    637658      size_t len,len1;
     
    639660      len = JS_GetStringLength(jsmsg);
    640661      jsval nvp;
    641       JS_GetProperty(cx, JSVAL_TO_OBJECT(t), JS_EncodeString(cx,jsmsg), &nvp);
     662      tmp=JS_EncodeString(cx,jsmsg);
     663      JS_GetProperty(cx, JSVAL_TO_OBJECT(t), tmp, &nvp);
    642664      jsmsg1 = JS_ValueToString(cx,nvp);
    643665      len1 = JS_GetStringLength(jsmsg1);
    644 #ifdef JS_DEBUG
    645       fprintf(stderr,"Enumerate id : %d [ %s => %s ]\n",index,JS_EncodeString(cx,jsmsg),JS_EncodeString(cx,jsmsg1));
     666      tmp1=JS_EncodeString(cx,jsmsg1);
     667#ifdef JS_DEBUG
     668      fprintf(stderr,"Enumerate id : %d [ %s => %s ]\n",index,tmp,tmp1);
    646669#endif
    647670      if(res!=NULL){
    648671#ifdef JS_DEBUG
    649         fprintf(stderr,"%s - %s\n",JS_EncodeString(cx,jsmsg),JS_EncodeString(cx,jsmsg1));
    650 #endif
    651         addToMap(res,JS_EncodeString(cx,jsmsg),JS_EncodeString(cx,jsmsg1));
     672        fprintf(stderr,"%s - %s\n",tmp,tmp1);
     673#endif
     674        addToMap(res,tmp,tmp1);
    652675      }
    653676      else{
    654         res=createMap(JS_EncodeString(cx,jsmsg),JS_EncodeString(cx,jsmsg1));
     677        res=createMap(tmp,tmp1);
    655678        res->next=NULL;
    656679      }
     680      free(tmp);
     681      free(tmp1);
    657682#ifdef JS_DEBUG
    658683      dumpMap(res);
    659684#endif
    660685    }
     686    JS_DestroyIdArray(cx,idp);
    661687  }
    662688#ifdef JS_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