• Victor Stinner's avatar
    bpo-18835: Cleanup pymalloc (#4200) · 9ed83c40
    Victor Stinner yazdı
    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.
    9ed83c40
obmalloc.c 58.8 KB