]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-18835: Cleanup pymalloc (#4200)
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 31 Oct 2017 19:18:10 +0000 (12:18 -0700)
committerGitHub <noreply@github.com>
Tue, 31 Oct 2017 19:18:10 +0000 (12:18 -0700)
commit9ed83c40855b57c10988f76770a4eb825e034cd8
treed3652389cce48f88a8405fcc944f0524397d46c6
parentec2cbdd1dff2c51788136480b2085e77506ebf34
bpo-18835: Cleanup pymalloc (#4200)

Cleanup pymalloc:

* Rename _PyObject_Alloc() to pymalloc_alloc()
* Rename _PyObject_FreeImpl() to pymalloc_free()
* Rename _PyObject_Realloc() to pymalloc_realloc()
* pymalloc_alloc() and pymalloc_realloc() don't fallback on the raw
  allocator anymore, it now must be done by the caller
* Add "success" and "failed" labels to pymalloc_alloc() and
  pymalloc_free()
* pymalloc_alloc() and pymalloc_free() don't update
  num_allocated_blocks anymore: it should be done in the caller
* _PyObject_Calloc() is now responsible to fill the memory block
  allocated by pymalloc with zeros
* Simplify pymalloc_alloc() prototype
* _PyObject_Realloc() now calls _PyObject_Malloc() rather than
  calling directly pymalloc_alloc()

_PyMem_DebugRawAlloc() and _PyMem_DebugRawRealloc():

* document the layout of a memory block
* don't increase the serial number if the allocation failed
* check for integer overflow before computing the total size
* add a 'data' variable to make the code easiler to follow

test_setallocators() of _testcapimodule.c now test also the context.
Modules/_testcapimodule.c
Objects/obmalloc.c