Changeset fda61d3


Ignore:
Timestamp:
May 20, 2011, 3:59:31 PM (13 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.10, release-1.8, release-1.9
Children:
351c535
Parents:
3b8a563
git-author:
David Benjamin <davidben@mit.edu> (05/07/11 15:17:37)
git-committer:
David Benjamin <davidben@mit.edu> (05/20/11 15:59:31)
Message:
g_strdup and g_new0 never fail

Remove pointless failure checks cluttering the code.
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • dict.c

    rf25df21 rfda61d3  
    6262int owl_dict_get_keys(const owl_dict *d, owl_list *l) {
    6363  int i;
    64   char *dupk;
    6564  for (i=0; i<d->size; i++) {
    66     if ((dupk = g_strdup(d->els[i].k)) == NULL) return(-1);
    67     owl_list_append_element(l, dupk);
     65    owl_list_append_element(l, g_strdup(d->els[i].k));
    6866  }
    6967  return(0);
     
    8482{
    8583  int pos, found;
    86   char *dupk;
    8784  found = _owl_dict_find_pos(d, k, &pos);
    8885  if (found && delete_on_replace) {
     
    9996      if (d->els==NULL) return(-1);
    10097    }
    101     if ((dupk = g_strdup(k)) == NULL) return(-1);
    10298    if (pos!=d->size) {
    10399      /* shift forward to leave us a slot */
     
    106102    }
    107103    d->size++;
    108     d->els[pos].k = dupk;
     104    d->els[pos].k = g_strdup(k);
    109105    d->els[pos].v = v;   
    110106    return(0);
  • keymap.c

    r47e0a6a rfda61d3  
    99{
    1010  if (!name || !desc) return(-1);
    11   if ((km->name = g_strdup(name)) == NULL) return(-1);
    12   if ((km->desc = g_strdup(desc)) == NULL) return(-1);
    13   if (0 != owl_list_create(&km->bindings)) return(-1);
     11  km->name = g_strdup(name);
     12  km->desc = g_strdup(desc);
     13  owl_list_create(&km->bindings);
    1414  km->parent = NULL;
    1515  km->default_fn = default_fn;
  • list.c

    rddbbcffa rfda61d3  
    55#define GROWBY 3 / 2
    66
    7 int owl_list_create(owl_list *l)
     7void owl_list_create(owl_list *l)
    88{
    99  l->size=0;
    1010  l->list=g_new(void *, INITSIZE);
    1111  l->avail=INITSIZE;
    12   if (l->list==NULL) return(-1);
    13   return(0);
    1412}
    1513
Note: See TracChangeset for help on using the changeset viewer.