Changeset 3b8a563


Ignore:
Timestamp:
May 20, 2011, 3:59:31 PM (10 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.8, release-1.9
Children:
fda61d3
Parents:
7865479
git-author:
David Benjamin <davidben@mit.edu> (05/07/11 15:12:09)
git-committer:
David Benjamin <davidben@mit.edu> (05/20/11 15:59:31)
Message:
Remove NULL checks before calling g_free

g_free handles the NULL check for us.
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • cmd.c

    r6a71113 r3b8a563  
    135135void owl_cmd_cleanup(owl_cmd *cmd)
    136136{
    137   if (cmd->name) g_free(cmd->name);
    138   if (cmd->summary) g_free(cmd->summary);
    139   if (cmd->usage) g_free(cmd->usage);
    140   if (cmd->description) g_free(cmd->description);
    141   if (cmd->cmd_aliased_to) g_free(cmd->cmd_aliased_to);
     137  g_free(cmd->name);
     138  g_free(cmd->summary);
     139  g_free(cmd->usage);
     140  g_free(cmd->description);
     141  g_free(cmd->cmd_aliased_to);
    142142  if (cmd->cmd_perl) owl_perlconfig_cmd_cleanup(cmd);
    143143}
  • commands.c

    rc809f5e r3b8a563  
    12881288  }
    12891289  owl_function_nextmsg_full(filter, skip_deleted, last_if_none);
    1290   if (filter) g_free(filter);
     1290  g_free(filter);
    12911291  return(NULL);
    12921292}
     
    13181318  }
    13191319  owl_function_prevmsg_full(filter, skip_deleted, first_if_none);
    1320   if (filter) g_free(filter);
     1320  g_free(filter);
    13211321  return(NULL);
    13221322}
     
    16911691  commands = g_strsplit_set(newbuff, ";", 0);
    16921692  for (i = 0; commands[i] != NULL; i++) {
    1693     if (lastrv) {
    1694       g_free(lastrv);
    1695     }
     1693    g_free(lastrv);
    16961694    lastrv = owl_function_command(commands[i]);
    16971695  }
  • editwin.c

    r47e0a6a r3b8a563  
    317317  }
    318318
    319   if (locktext)
    320     g_free(locktext);
     319  g_free(locktext);
    321320
    322321  oe_set_index(e, lock);
  • functions.c

    r7865479 r3b8a563  
    3232  char *rv;
    3333  rv=owl_function_command(cmdbuff);
    34   if (rv) g_free(rv);
     34  g_free(rv);
    3535}
    3636
     
    453453
    454454  if (rv || status) {
    455     if(cryptmsg) g_free(cryptmsg);
     455    g_free(cryptmsg);
    456456    g_free(old_msg);
    457457    owl_function_error("Error in zcrypt, possibly no key found.  Message not sent.");
     
    991991  /* execute the commands in shutdown */
    992992  ret = owl_perlconfig_execute("BarnOwl::Hooks::_shutdown();");
    993   if (ret) g_free(ret);
     993  g_free(ret);
    994994
    995995  /* signal our child process, if any */
     
    23582358done:
    23592359  g_free(class);
    2360   if (instance) {
    2361     g_free(instance);
    2362   }
     2360  g_free(instance);
    23632361  return(filtname);
    23642362}
  • global.c

    r7b4f3be r3b8a563  
    505505
    506506void owl_global_set_startupargs(owl_global *g, int argc, char **argv) {
    507   if (g->startupargs) g_free(g->startupargs);
     507  g_free(g->startupargs);
    508508  g->startupargs = g_strjoinv(" ", argv);
    509509}
  • keybinding.c

    rd07af84 r3b8a563  
    6969void owl_keybinding_delete(owl_keybinding *kb)
    7070{
    71   if (kb->keys) g_free(kb->keys);
    72   if (kb->desc) g_free(kb->desc);
    73   if (kb->command) g_free(kb->command);
     71  g_free(kb->keys);
     72  g_free(kb->desc);
     73  g_free(kb->command);
    7474  g_free(kb);
    7575}
  • owl.c

    r9efa5bd r3b8a563  
    552552  owl_function_debugmsg("startup: executing perl startup, if applicable");
    553553  perlout = owl_perlconfig_execute("BarnOwl::Hooks::_startup();");
    554   if (perlout) g_free(perlout);
     554  g_free(perlout);
    555555
    556556  /* welcome message */
  • perlconfig.c

    rf2d71cfa r3b8a563  
    467467                                           :"BarnOwl::_receive_msg_legacy_wrap", m);
    468468  }
    469   if (ptr) g_free(ptr);
     469  g_free(ptr);
    470470}
    471471
     
    478478                                           :"BarnOwl::Hooks::_new_msg", m);
    479479  }
    480   if (ptr) g_free(ptr);
     480  g_free(ptr);
    481481}
    482482
  • perlglue.xs

    r6a71113 r3b8a563  
    5757                RETVAL
    5858        CLEANUP:
    59                 if (rv) g_free(rv);
     59                g_free(rv);
    6060
    6161SV *
     
    114114                RETVAL
    115115        CLEANUP:
    116                 if (rv) g_free(rv);
     116                g_free(rv);
    117117
    118118const utf8 *
     
    141141                RETVAL
    142142    CLEANUP:
    143                 if (rv) g_free(rv);
     143                g_free(rv);
    144144
    145145void
     
    324324                RETVAL
    325325        CLEANUP:
    326                 if (rv)
    327                         g_free(rv);
     326                g_free(rv);
    328327
    329328void
  • variable.c

    rf203cad r3b8a563  
    641641
    642642void owl_variable_update(owl_variable *var, const char *summary, const char *desc) {
    643   if(var->summary) g_free(var->summary);
     643  g_free(var->summary);
    644644  var->summary = g_strdup(summary);
    645   if(var->description) g_free(var->description);
     645  g_free(var->description);
    646646  var->description = g_strdup(desc);
    647647}
     
    651651  if(old) {
    652652    owl_variable_update(old, summ, desc);
    653     if(old->pval_default) g_free(old->pval_default);
     653    g_free(old->pval_default);
    654654    old->pval_default = g_strdup(initval);
    655655  } else {
     
    944944void owl_variable_delete_default(owl_variable *v)
    945945{
    946   if (v->val) g_free(v->val);
     946  g_free(v->val);
    947947}
    948948
     
    10761076    if (!v->validate_fn(v, newval)) return(-1);
    10771077  }
    1078   if (v->val) g_free(v->val);
     1078  g_free(v->val);
    10791079  v->val = g_strdup(newval);
    10801080  return(0);
  • view.c

    rd4927a7 r3b8a563  
    160160{
    161161  owl_list_cleanup(&v->ml.list, NULL);
    162   if (v->name) g_free(v->name);
     162  g_free(v->name);
    163163}
  • zcrypt.c

    r1dd285b r3b8a563  
    476476
    477477  for(i = 0; i < MAX_SEARCH; i++) {
    478     if(varname[i] != NULL) {
    479       g_free(varname[i]);
    480     }
    481   }
    482 
    483   if(filename != NULL) {
    484     g_free(filename);
    485   }
     478    g_free(varname[i]);
     479  }
     480
     481  g_free(filename);
    486482
    487483  return keyfile;
     
    773769  err = call_filter("gpg", argv, in, &out, &status);
    774770  if(err || status) {
    775     if(out) g_free(out);
     771    g_free(out);
    776772    return FALSE;
    777773  }
     
    856852  err = call_filter("gpg", argv, in, &out, &status);
    857853  if(err || status) {
    858     if(out) g_free(out);
     854    g_free(out);
    859855    return FALSE;
    860856  }
  • zephyr.c

    rf203cad r3b8a563  
    417417    return 0;
    418418  }
    419   if (buffer)
    420     g_free(buffer);
     419  g_free(buffer);
    421420
    422421  return owl_zephyr_loadsubs_helper(subs, count);
  • zwrite.c

    r3f52e14 r3b8a563  
    185185void owl_zwrite_set_message_raw(owl_zwrite *z, const char *msg)
    186186{
    187   if (z->message) g_free(z->message);
     187  g_free(z->message);
    188188  z->message = owl_validate_utf8(msg);
    189189}
     
    195195  char *tmp = NULL, *tmp2;
    196196
    197   if (z->message) g_free(z->message);
     197  g_free(z->message);
    198198
    199199  j=owl_list_get_size(&(z->recips));
     
    289289void owl_zwrite_set_opcode(owl_zwrite *z, const char *opcode)
    290290{
    291   if (z->opcode) g_free(z->opcode);
     291  g_free(z->opcode);
    292292  z->opcode=owl_validate_utf8(opcode);
    293293}
     
    306306void owl_zwrite_set_zsig(owl_zwrite *z, const char *zsig)
    307307{
    308   if(z->zsig) g_free(z->zsig);
     308  g_free(z->zsig);
    309309  z->zsig = g_strdup(zsig);
    310310}
     
    353353{
    354354  owl_list_cleanup(&(z->recips), &g_free);
    355   if (z->cmd) g_free(z->cmd);
    356   if (z->zwriteline) g_free(z->zwriteline);
    357   if (z->class) g_free(z->class);
    358   if (z->inst) g_free(z->inst);
    359   if (z->opcode) g_free(z->opcode);
    360   if (z->realm) g_free(z->realm);
    361   if (z->message) g_free(z->message);
    362   if (z->zsig) g_free(z->zsig);
     355  g_free(z->cmd);
     356  g_free(z->zwriteline);
     357  g_free(z->class);
     358  g_free(z->inst);
     359  g_free(z->opcode);
     360  g_free(z->realm);
     361  g_free(z->message);
     362  g_free(z->zsig);
    363363}
    364364
Note: See TracChangeset for help on using the changeset viewer.