Changeset 6a72ff0


Ignore:
Timestamp:
Aug 20, 2016, 7:41:23 PM (4 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master, pitchshift, sampler, timestretch, yinfft+
Children:
5d8cc71
Parents:
773a7f3
Message:

python/lib/gen_code.py: improve del_ function, safer DECREF, fix indentation, emit RuntimeError?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/lib/gen_code.py

    r773a7f3 r6a72ff0  
    307307  // return -1 and set error string on failure
    308308  if (self->o == NULL) {{
    309     PyErr_Format (PyExc_Exception, "failed creating {shortname}");
     309    PyErr_Format (PyExc_RuntimeError, "failed creating {shortname}");
    310310    return -1;
    311311  }}
     
    349349            if input_param['type'] == 'fmat_t *':
    350350                out += """
    351     free(self->{0[name]}.data);""".format(input_param)
     351  free(self->{0[name]}.data);""".format(input_param)
    352352        for o in self.outputs:
    353353            name = o['name']
    354354            del_out = delfromtype_fn[o['type']]
    355355            out += """
    356     {del_out}(self->{name});""".format(del_out = del_out, name = name)
     356  if (self->{name}) {{
     357    {del_out}(self->{name});
     358  }}""".format(del_out = del_out, name = name)
    357359        del_fn = get_name(self.del_proto)
    358360        out += """
    359     if (self->o) {{
    360         {del_fn}(self->o);
    361     }}
    362     Py_TYPE(self)->tp_free((PyObject *) self);
     361  if (self->o) {{
     362    {del_fn}(self->o);
     363  }}
     364  Py_TYPE(self)->tp_free((PyObject *) self);
    363365}}
    364366""".format(del_fn = del_fn)
Note: See TracChangeset for help on using the changeset viewer.