Changeset 81a5686


Ignore:
Timestamp:
Jun 19, 2011, 1:08:11 AM (13 years ago)
Author:
Anders Kaseorg <andersk@mit.edu>
Children:
4798b36
Parents:
3756803
git-author:
Anders Kaseorg <andersk@mit.edu> (06/18/11 20:42:19)
git-committer:
Anders Kaseorg <andersk@mit.edu> (06/19/11 01:08:11)
Message:
variables_to_init: Copy string literals

This squashes the rest of the -Wwrite-strings warnings from
temporarily storing string literals in char * fields.

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

Legend:

Unmodified
Added
Removed
  • variable.c

    r3756803 r81a5686  
    77
    88#define OWLVAR_BOOL(name,default,summary,description) \
    9         { name, OWL_VARIABLE_BOOL, NULL, default, "on,off", summary,description, NULL, \
     9        { g_strdup(name), OWL_VARIABLE_BOOL, NULL, default, "on,off", g_strdup(summary), g_strdup(description), NULL, \
    1010        NULL, NULL, NULL, NULL, NULL, NULL }
    1111
    1212#define OWLVAR_BOOL_FULL(name,default,summary,description,validate,set,get) \
    13         { name, OWL_VARIABLE_BOOL, NULL, default, "on,off", summary,description, NULL, \
     13        { g_strdup(name), OWL_VARIABLE_BOOL, NULL, default, "on,off", g_strdup(summary), g_strdup(description), NULL, \
    1414        validate, set, NULL, get, NULL, NULL }
    1515
    1616#define OWLVAR_INT(name,default,summary,description) \
    17         { name, OWL_VARIABLE_INT, NULL, default, "<int>", summary,description, NULL, \
     17        { g_strdup(name), OWL_VARIABLE_INT, NULL, default, "<int>", g_strdup(summary), g_strdup(description), NULL, \
    1818        NULL, NULL, NULL, NULL, NULL, NULL }
    1919
    2020#define OWLVAR_INT_FULL(name,default,summary,description,validset,validate,set,get) \
    21         { name, OWL_VARIABLE_INT, NULL, default, validset, summary,description, NULL, \
     21        { g_strdup(name), OWL_VARIABLE_INT, NULL, default, validset, g_strdup(summary), g_strdup(description), NULL, \
    2222        validate, set, NULL, get, NULL, NULL }
    2323
    2424#define OWLVAR_PATH(name,default,summary,description) \
    25         { name, OWL_VARIABLE_STRING, default, 0, "<path>", summary,description,  NULL, \
     25        { g_strdup(name), OWL_VARIABLE_STRING, g_strdup(default), 0, "<path>", g_strdup(summary), g_strdup(description),  NULL, \
    2626        NULL, NULL, NULL, NULL, NULL, NULL }
    2727
    2828#define OWLVAR_STRING(name,default,summary,description) \
    29         { name, OWL_VARIABLE_STRING, default, 0, "<string>", summary,description, NULL, \
     29        { g_strdup(name), OWL_VARIABLE_STRING, g_strdup(default), 0, "<string>", g_strdup(summary), g_strdup(description), NULL, \
    3030        NULL, NULL, NULL, NULL, NULL, NULL }
    3131
    3232#define OWLVAR_STRING_FULL(name,default,validset,summary,description,validate,set,get) \
    33         { name, OWL_VARIABLE_STRING, default, 0, validset, summary,description, NULL, \
     33        { g_strdup(name), OWL_VARIABLE_STRING, g_strdup(default), 0, validset, g_strdup(summary), g_strdup(description), NULL, \
    3434        validate, set, NULL, get, NULL, NULL }
    3535
     
    3838 * correspond to the values that may be specified. */
    3939#define OWLVAR_ENUM(name,default,summary,description,validset) \
    40         { name, OWL_VARIABLE_INT, NULL, default, validset, summary,description, NULL, \
     40        { g_strdup(name), OWL_VARIABLE_INT, NULL, default, validset, g_strdup(summary), g_strdup(description), NULL, \
    4141        owl_variable_enum_validate, \
    4242        NULL, owl_variable_enum_set_fromstring, \
     
    4545
    4646#define OWLVAR_ENUM_FULL(name,default,summary,description,validset,validate, set, get) \
    47         { name, OWL_VARIABLE_INT, NULL, default, validset, summary,description, NULL, \
     47        { g_strdup(name), OWL_VARIABLE_INT, NULL, default, validset, g_strdup(summary), g_strdup(description), NULL, \
    4848        validate, \
    4949        set, owl_variable_enum_set_fromstring, \
     
    443443  };
    444444
    445   return owl_variable_dict_add_from_list(vd, variables_to_init);
     445  int ret = owl_variable_dict_add_from_list(vd, variables_to_init);
     446  owl_variable *var;
     447  for (var = variables_to_init; var->name != NULL; var++)
     448    owl_variable_cleanup(var);
     449  return ret;
    446450}
    447451
     
    729733}
    730734
    731 void owl_variable_delete(owl_variable *v)
     735void owl_variable_cleanup(owl_variable *v)
    732736{
    733737  if (v->delete_fn) v->delete_fn(v);
     
    737741  if (v->type == OWL_VARIABLE_STRING)
    738742    g_free(v->pval_default);
     743}
     744
     745void owl_variable_delete(owl_variable *v)
     746{
     747  owl_variable_cleanup(v);
    739748  g_free(v);
    740749}
Note: See TracChangeset for help on using the changeset viewer.