Skip to content

Conversation

@vstinner
Copy link
Member

@vstinner vstinner commented Oct 31, 2017

Cleanup pymalloc:

  • Rename _PyObject_Alloc() to pymalloc_alloc()
  • Rename _PyObject_FreeImpl() to pymalloc_free()
  • pymalloc_alloc() doesn'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():

  • 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

Enhance test_setallocators() of _testcapimodule.c: test also the
context.

https://bugs.python.org/issue18835

@vstinner
Copy link
Member Author

Since my PR #4089 became too big, I extracted my changes to "cleanup" obmalloc.c, especially the changes to cleanup the pymalloc allocator. So once this PR will be merged, PR #4089 will be easier to review.

@vstinner
Copy link
Member Author

Hum, the Travis CI failure seems unrelated:

======================================================================

FAIL: test_create_connection (test.test_socket.NetworkConnectionNoServer)

----------------------------------------------------------------------

Traceback (most recent call last):

  File "/home/travis/build/python/cpython/Lib/test/test_socket.py", line 4537, in test_create_connection

    self.assertIn(cm.exception.errno, expected_errnos)

AssertionError: 99 not found in [111, 101]

I scheduled a new build.

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.
@vstinner
Copy link
Member Author

Hum, the Travis CI failure seems unrelated: (...)

I reported the issue as https://bugs.python.org/issue31910

@vstinner vstinner merged commit 9ed83c4 into python:master Oct 31, 2017
@vstinner vstinner deleted the pymalloc branch October 31, 2017 19:18
@vstinner
Copy link
Member Author

While this change seems big, most changes are related to an indentation change.

embray pushed a commit to embray/cpython that referenced this pull request Nov 9, 2017
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants