Changeset 6cd90c1aee8624c59f25eab79180b581fdacf1be

Show
Ignore:
Timestamp:
05/22/10 19:02:54 (9 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1274554974 +0000
git-parent:

[dc4646a0468cf2ae4a429dc6690c19f600af2048]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1274554974 +0000
Message:

cleanup memory allocations in storagenode lookups, fixes #282

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/stratcon_datastore.c

    r37f5a09 r6cd90c1  
    971971get_dsn_from_storagenode_id(int id, int can_use_db, char **fqdn_out) { 
    972972  void *vinfo; 
    973   const char *dsn = NULL, *fqdn = NULL; 
     973  char *dsn = NULL, *fqdn = NULL; 
    974974  int found = 0; 
    975975  storagenode_info *info = NULL; 
     
    10001000      PG_GET_STR_COL(dsn, 0, "dsn"); 
    10011001      PG_GET_STR_COL(fqdn, 0, "fqdn"); 
     1002      fqdn = fqdn ? strdup(fqdn) : NULL; 
     1003      dsn = dsn ? strdup(dsn) : NULL; 
    10021004    } 
    10031005    PQclear(d->res); 
     
    10091011  if(fqdn) { 
    10101012    info = calloc(1, sizeof(*info)); 
    1011     info->fqdn = strdup(fqdn)
     1013    info->fqdn = fqdn
    10121014    if(fqdn_out) *fqdn_out = info->fqdn; 
    1013     info->dsn = dsn ? strdup(dsn) : NULL
     1015    info->dsn = dsn
    10141016    info->storagenode_id = id; 
    10151017    pthread_mutex_lock(&storagenode_to_info_cache_lock); 
     
    13221324      PG_GET_STR_COL(dsn, 0, "dsn"); 
    13231325      PG_GET_STR_COL(new_remote_cn, 0, "remote_cn"); 
     1326      fqdn = fqdn ? strdup(fqdn) : NULL; 
     1327      dsn = dsn ? strdup(dsn) : NULL; 
     1328      new_remote_cn = new_remote_cn ? strdup(new_remote_cn) : NULL; 
    13241329      PQclear(d->res); 
    13251330    } 
     
    13321337    } 
    13331338    /* Place in cache */ 
    1334     if(fqdn) fqdn = strdup(fqdn); 
    13351339    uuidinfo = calloc(1, sizeof(*uuidinfo)); 
    13361340    uuidinfo->sid = sid; 
     
    13801384  } 
    13811385 
    1382   if(fqdn_out) *fqdn_out = fqdn ? fqdn : (info ? info->fqdn : NULL)
    1383   if(dsn_out) *dsn_out = dsn ? dsn : (info ? info->dsn : NULL)
     1386  if(fqdn_out) *fqdn_out = info ? info->fqdn : NULL
     1387  if(dsn_out) *dsn_out = info ? info->dsn : NULL
    13841388  if(remote_cn_out) *remote_cn_out = uuidinfo->remote_cn; 
    13851389  if(storagenode_id_out) *storagenode_id_out = uuidinfo->storagenode_id; 
    13861390  if(sid_out) *sid_out = uuidinfo->sid; 
     1391  if(fqdn) free(fqdn); 
     1392  if(dsn) free(dsn); 
     1393  if(new_remote_cn) free(new_remote_cn); 
    13871394  return 0; 
    13881395}