# entry.buffer_aux.buffer_info_var.cname))
def get_release_buffer_code(entry):
- return "if (%s != Py_None) __Pyx_ReleaseBuffer(%s, &%s)" % (
- entry.cname,
+ return "__Pyx_ReleaseBuffer(%s, &%s)" % (
entry.cname,
entry.buffer_aux.buffer_info_var.cname)
if is_initialized:
# Release any existing buffer
- code.put('if (%s != Py_None) ' % lhs_cname)
- code.begin_block();
code.putln('__Pyx_ReleaseBuffer(%s, &%s);' % (
lhs_cname, bufstruct))
- code.end_block()
# Acquire
retcode_cname = code.funcstate.allocate_temp(PyrexTypes.c_int_type)
code.putln("%s = %s;" % (retcode_cname, getbuffer % rhs_cname))
static void __Pyx_BufferNdimError(Py_buffer* buffer, int expected_ndim); /*proto*/
""", """
static INLINE void __Pyx_ReleaseBuffer(PyObject* obj, Py_buffer* info) {
+ if (info->buf == NULL) return;
if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL;
PyObject_ReleaseBuffer(obj, info);
}
for entry in lenv.var_entries:
if entry.type.is_pyobject and entry.init_to_none and entry.used:
code.put_init_var_to_py_none(entry)
+ if entry.type.is_buffer and entry.buffer_aux.buffer_info_var.used:
+ code.putln("%s.buf = NULL;" % entry.buffer_aux.buffer_info_var.cname)
# ----- Check and convert arguments
self.generate_argument_type_tests(code)
# ----- Function body
# body StatNode or None
# entry Symtab.Entry
# base_type PyExtensionType or None
+ # bufferdefaults dict or None Declares defaults for a buffer
+
child_attrs = ["body"]
+ bufferdefaults = None
def analyse_declarations(self, env):
#print "CClassDefNode.analyse_declarations:", self.class_name