[Python-Dev] Proposal: C API Macro to decref and set to NULL
Skip Montanaro
skip at pobox.com
Tue Jul 13 04:36:32 CEST 2004
Jim> The correct way to do this is something like:
Jim> tmp = self->foo;
Jim> self-> foo = NULL;
Jim> Py_XDECREF(tmp);
Jim> I suggest that there should be a standard macro to automate this.
Jim> Py_CLEAR(self->foo)
Jim> This would be defined to be the same result as Py_XDECREF except
Jim> that the argument will be set to NULL.
Jim> Thoughts?
Just my two cents, but the name suggests to me that it's doing more than a
simple decref and set to NULL. I can't think of anything else off the top
of my head that seems obviously better though.
Skip
More information about the Python-Dev
mailing list