Commit 514e1c65 authored by Stefan Behnel's avatar Stefan Behnel

revert to using malloc/free for data buffer allocation in case external code...

revert to using malloc/free for data buffer allocation in case external code wants to fiddle with it
parent 36939ee3
...@@ -163,7 +163,9 @@ cdef class array: ...@@ -163,7 +163,9 @@ cdef class array:
self.free_data = allocate_buffer self.free_data = allocate_buffer
self.dtype_is_object = format == b'O' self.dtype_is_object = format == b'O'
if allocate_buffer: if allocate_buffer:
self.data = <char *>PyMem_Malloc(self.len) # use malloc() for backwards compatibility
# in case external code wants to change the data pointer
self.data = <char *>malloc(self.len)
if not self.data: if not self.data:
raise MemoryError("unable to allocate array data.") raise MemoryError("unable to allocate array data.")
...@@ -207,7 +209,7 @@ cdef class array: ...@@ -207,7 +209,7 @@ cdef class array:
if self.dtype_is_object: if self.dtype_is_object:
refcount_objects_in_slice(self.data, self._shape, refcount_objects_in_slice(self.data, self._shape,
self._strides, self.ndim, False) self._strides, self.ndim, False)
PyMem_Free(self.data) free(self.data)
PyMem_Free(self._shape) PyMem_Free(self._shape)
property memview: property memview:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment