Changeset 63d3e4e for variable.c


Ignore:
Timestamp:
Feb 21, 2013, 4:42:21 PM (9 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master
Children:
523146b
Parents:
f41956d
git-author:
David Benjamin <davidben@mit.edu> (06/10/12 15:14:15)
git-committer:
David Benjamin <davidben@mit.edu> (02/21/13 16:42:21)
Message:
Make GClosure invokes more mechanical

We don't really need some of those g_value_unsets, but we may as well
avoid making assumptions. Someone else might copy-and-paste the code
later and get it wrong.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • variable.c

    rf41956d r63d3e4e  
    812812  char *tostring;
    813813  GValue values[] = {G_VALUE_INIT, G_VALUE_INIT};
    814   GValue *value_box = &values[1];
    815814  GValue return_box = G_VALUE_INIT;
     815
    816816  int set_successfully = -1;
    817817  if (!v->set_fromstring_fn) {
     
    819819    return -1;   
    820820  }
     821
    821822  g_value_init(&values[0], G_TYPE_POINTER);
    822823  g_value_set_pointer(&values[0], NULL);
    823   g_value_init(value_box, G_TYPE_STRING);
    824   g_value_set_static_string(value_box, value);
     824  g_value_init(&values[1], G_TYPE_STRING);
     825  g_value_set_static_string(&values[1], value);
    825826  g_value_init(&return_box, G_TYPE_INT);
    826827  g_closure_invoke(v->set_fromstring_fn, &return_box, 2, values, NULL);
     828
    827829  set_successfully = g_value_get_int(&return_box);
    828830  if (0 != set_successfully) {
     
    838840    g_free(tostring);
    839841  }
    840   g_value_unset(value_box);
     842
     843  g_value_unset(&return_box);
     844  g_value_unset(&values[1]);
     845  g_value_unset(&values[0]);
    841846  return set_successfully;
    842847}
     
    889894
    890895  ret = g_value_dup_string(&tostring_box);
     896
    891897  g_value_unset(&tostring_box);
    892 
     898  g_value_unset(&instance);
    893899  return ret;
    894900}
Note: See TracChangeset for help on using the changeset viewer.