Skip to content

Commit de3db13

Browse files
committed
DOC: document the 'free' signature
1 parent f14aac4 commit de3db13

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

doc/neps/nep-0049.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,16 @@ NumPy C-API functions
134134
void (*free) (void *ctx, void *ptr, size_t size);
135135
} PyDataMemAllocator;
136136
137+
The use of a ``size`` parameter in ``free`` differentiates this struct from
138+
the :c:type:`PyMemAllocatorEx` struct in Python. This call signature is
139+
used internally in NumPy currently, and also in other places for instance
140+
C++11 (maybe older): https://en.cppreference.com/w/cpp/memory/allocator/deallocate
141+
C++17: https://en.cppreference.com/w/cpp/memory/polymorphic_allocator/deallocate
142+
Rust (allocator_api): https://doc.rust-lang.org/std/alloc/trait.Allocator.html#tymethod.deallocate
143+
144+
The user must keep track of ``size`` and make sure it is consistent with
145+
the ``alloc`` parameter.
146+
137147
.. c:function:: const PyDataMem_Handler * PyDataMem_SetHandler(PyDataMem_Handler *handler)
138148
139149
Sets a new allocation policy. If the input value is ``NULL``, will reset

0 commit comments

Comments
 (0)