Changeset 606


Ignore:
Timestamp:
Mar 11, 2015, 11:55:20 AM (10 years ago)
Author:
david
Message:

fix leak

Location:
branches/PublicaMundi_David-devel/zoo-project/zoo-kernel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_json.c

    r602 r606  
    3333
    3434map* jsontomap(json_object * jobj){
    35     map *m;
     35    map *m = (map *) malloc (MAP_SIZE);
     36    int i = 0;
    3637    json_object_object_foreach(jobj, key, val){
    3738        if (json_object_is_type(val, json_type_string)){
    38             addMapToMap(&m,createMap(key,json_object_get_string(val)));
     39            if (i==0){
     40                m->name = zStrdup(key);
     41                m->value = zStrdup(json_object_get_string(val));
     42                m->next = NULL;
     43                i = 1;
     44            }
     45            else {
     46                map *tmp=createMap(key,json_object_get_string(val));
     47                addMapToMap(&m,tmp);
     48                freeMap(&tmp);
     49                free(tmp);
     50           }
    3951        }
    4052        else {
     53            fprintf(stderr,"jsontomap not map :%s \n",key);
    4154            /* Attention ce n'est pas une map */
    4255            return NULL;
     
    4659}
    4760
    48 int jsontomaps(json_object * jobj,maps ** m){
    49     maps *maps_tmp;
     61maps * jsontomaps(json_object * jobj){
     62    maps *mm = (maps *) malloc (MAPS_SIZE);
     63    int i =0;
    5064    json_object_object_foreach(jobj, key, val){
    51         maps_tmp = (maps *) malloc (MAPS_SIZE);
    52         maps_tmp->content = jsontomap(val);
    53         maps_tmp->name = zStrdup(key);
    54         addMapsToMaps(m,maps_tmp);
     65        if (i ==0){
     66            mm->content = jsontomap(val);
     67            mm->name = zStrdup(key);
     68            mm->next = NULL;
     69            i = 1;
     70        }
     71        else {
     72            maps *maps_tmp;
     73            maps_tmp = (maps *) malloc (MAPS_SIZE);
     74            maps_tmp->content = jsontomap(val);
     75            maps_tmp->name = zStrdup(key);
     76            maps_tmp->next = NULL;
     77            addMapsToMaps(&mm,maps_tmp);
     78            freeMaps(&maps_tmp);
     79            free(maps_tmp);
     80            maps_tmp = NULL;
     81       }
    5582    }
    56     return 0;
     83    return mm;
    5784}
    5885 
  • branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_json.h

    r602 r606  
    1111
    1212map* jsontomap(json_object * jobj);
    13 int jsontomaps(json_object * jobj,maps **m);
     13maps*  jsontomaps(json_object * jobj);
    1414
    1515#endif
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