summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormattip <matti.picus@gmail.com>2021-07-14 12:28:42 +0300
committermattip <matti.picus@gmail.com>2021-07-14 12:28:42 +0300
commitde3db138db6641ef6cb2f9b50cc7f7c8ff6b59c0 (patch)
treecfef4002f7f0767c46aaaf4355291bb9f2c66b2c
parentf14aac43e3b83bec204719fa2efc051a07fca265 (diff)
downloadnumpy-de3db138db6641ef6cb2f9b50cc7f7c8ff6b59c0.tar.gz
DOC: document the 'free' signature
-rw-r--r--doc/neps/nep-0049.rst10
1 files changed, 10 insertions, 0 deletions
diff --git a/doc/neps/nep-0049.rst b/doc/neps/nep-0049.rst
index 3c74eceb1..d258f7999 100644
--- a/doc/neps/nep-0049.rst
+++ b/doc/neps/nep-0049.rst
@@ -134,6 +134,16 @@ NumPy C-API functions
void (*free) (void *ctx, void *ptr, size_t size);
} PyDataMemAllocator;
+ The use of a ``size`` parameter in ``free`` differentiates this struct from
+ the :c:type:`PyMemAllocatorEx` struct in Python. This call signature is
+ used internally in NumPy currently, and also in other places for instance
+ C++11 (maybe older): https://en.cppreference.com/w/cpp/memory/allocator/deallocate
+ C++17: https://en.cppreference.com/w/cpp/memory/polymorphic_allocator/deallocate
+ Rust (allocator_api): https://doc.rust-lang.org/std/alloc/trait.Allocator.html#tymethod.deallocate
+
+ The user must keep track of ``size`` and make sure it is consistent with
+ the ``alloc`` parameter.
+
.. c:function:: const PyDataMem_Handler * PyDataMem_SetHandler(PyDataMem_Handler *handler)
Sets a new allocation policy. If the input value is ``NULL``, will reset