Changeset 96828e4 for variable.c


Ignore:
Timestamp:
Feb 11, 2011, 4:31:33 PM (11 years ago)
Author:
Anders Kaseorg <andersk@mit.edu>
Branches:
master, release-1.8, release-1.9
Children:
35b6eb9
Parents:
9518a85
git-author:
Anders Kaseorg <andersk@mit.edu> (08/27/09 00:51:45)
git-committer:
Anders Kaseorg <andersk@mit.edu> (02/11/11 16:31:33)
Message:
Replace owl_malloc with g_new and g_new0.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Reviewed-by: Karl Ramm <kcr@mit.edu>
File:
1 edited

Legend:

Unmodified
Added
Removed
  • variable.c

    rd275eb2 r96828e4  
    479479  if (owl_dict_create(vd)) return(-1);
    480480  for (var = variables_to_init; var->name != NULL; var++) {
    481     cur = owl_malloc(sizeof(owl_variable));
     481    cur = g_new(owl_variable, 1);
    482482    *cur = *var;
    483483    /* strdup all the strings so we can delete them consistently. */
     
    517517      if (!cur->delete_fn)
    518518        cur->delete_fn = owl_variable_delete_default;
    519       cur->val = owl_malloc(sizeof(int));
     519      cur->val = g_new(int, 1);
    520520      cur->set_fn(cur, &cur->ival_default);
    521521      break;
     
    533533      if (!cur->delete_fn)
    534534        cur->delete_fn = owl_variable_delete_default;
    535       cur->val = owl_malloc(sizeof(int));
     535      cur->val = g_new(int, 1);
    536536      cur->set_fn(cur, &cur->ival_default);
    537537      break;
     
    551551
    552552owl_variable * owl_variable_newvar(const char *name, const char *summary, const char * description) {
    553   owl_variable * var = owl_malloc(sizeof(owl_variable));
    554   memset(var, 0, sizeof(owl_variable));
     553  owl_variable * var = g_new0(owl_variable, 1);
    555554  var->name = owl_strdup(name);
    556555  var->summary = owl_strdup(summary);
     
    601600    var->get_tostring_fn = owl_variable_int_get_tostring_default;
    602601    var->delete_fn = owl_variable_delete_default;
    603     var->val = owl_malloc(sizeof(int));
     602    var->val = g_new(int, 1);
    604603    var->set_fn(var, &initval);
    605604    owl_variable_dict_add_variable(vd, var);
     
    622621    var->get_tostring_fn = owl_variable_bool_get_tostring_default;
    623622    var->delete_fn = owl_variable_delete_default;
    624     var->val = owl_malloc(sizeof(int));
     623    var->val = g_new(int, 1);
    625624    var->set_fn(var, &initval);
    626625    owl_variable_dict_add_variable(vd, var);
Note: See TracChangeset for help on using the changeset viewer.