mirror of https://github.com/python/cpython
gh-93040 Wrap unused parameters in Objects/obmalloc.c with Py_UNUSED (#93175)
This commit is contained in:
parent
5695c0e0a2
commit
9485a0dbdd
|
@ -0,0 +1 @@
|
||||||
|
Wraps unused parameters in ``Objects/obmalloc.c`` with ``Py_UNUSED``.
|
|
@ -90,7 +90,7 @@ struct _PyTraceMalloc_Config _Py_tracemalloc_config = _PyTraceMalloc_Config_INIT
|
||||||
|
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
_PyMem_RawMalloc(void *ctx, size_t size)
|
_PyMem_RawMalloc(void *Py_UNUSED(ctx), size_t size)
|
||||||
{
|
{
|
||||||
/* PyMem_RawMalloc(0) means malloc(1). Some systems would return NULL
|
/* PyMem_RawMalloc(0) means malloc(1). Some systems would return NULL
|
||||||
for malloc(0), which would be treated as an error. Some platforms would
|
for malloc(0), which would be treated as an error. Some platforms would
|
||||||
|
@ -102,7 +102,7 @@ _PyMem_RawMalloc(void *ctx, size_t size)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
_PyMem_RawCalloc(void *ctx, size_t nelem, size_t elsize)
|
_PyMem_RawCalloc(void *Py_UNUSED(ctx), size_t nelem, size_t elsize)
|
||||||
{
|
{
|
||||||
/* PyMem_RawCalloc(0, 0) means calloc(1, 1). Some systems would return NULL
|
/* PyMem_RawCalloc(0, 0) means calloc(1, 1). Some systems would return NULL
|
||||||
for calloc(0, 0), which would be treated as an error. Some platforms
|
for calloc(0, 0), which would be treated as an error. Some platforms
|
||||||
|
@ -116,7 +116,7 @@ _PyMem_RawCalloc(void *ctx, size_t nelem, size_t elsize)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
_PyMem_RawRealloc(void *ctx, void *ptr, size_t size)
|
_PyMem_RawRealloc(void *Py_UNUSED(ctx), void *ptr, size_t size)
|
||||||
{
|
{
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
size = 1;
|
size = 1;
|
||||||
|
@ -124,7 +124,7 @@ _PyMem_RawRealloc(void *ctx, void *ptr, size_t size)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_PyMem_RawFree(void *ctx, void *ptr)
|
_PyMem_RawFree(void *Py_UNUSED(ctx), void *ptr)
|
||||||
{
|
{
|
||||||
free(ptr);
|
free(ptr);
|
||||||
}
|
}
|
||||||
|
@ -132,21 +132,22 @@ _PyMem_RawFree(void *ctx, void *ptr)
|
||||||
|
|
||||||
#ifdef MS_WINDOWS
|
#ifdef MS_WINDOWS
|
||||||
static void *
|
static void *
|
||||||
_PyObject_ArenaVirtualAlloc(void *ctx, size_t size)
|
_PyObject_ArenaVirtualAlloc(void *Py_UNUSED(ctx), size_t size)
|
||||||
{
|
{
|
||||||
return VirtualAlloc(NULL, size,
|
return VirtualAlloc(NULL, size,
|
||||||
MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
|
MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_PyObject_ArenaVirtualFree(void *ctx, void *ptr, size_t size)
|
_PyObject_ArenaVirtualFree(void *Py_UNUSED(ctx), void *ptr,
|
||||||
|
size_t Py_UNUSED(size))
|
||||||
{
|
{
|
||||||
VirtualFree(ptr, 0, MEM_RELEASE);
|
VirtualFree(ptr, 0, MEM_RELEASE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(ARENAS_USE_MMAP)
|
#elif defined(ARENAS_USE_MMAP)
|
||||||
static void *
|
static void *
|
||||||
_PyObject_ArenaMmap(void *ctx, size_t size)
|
_PyObject_ArenaMmap(void *Py_UNUSED(ctx), size_t size)
|
||||||
{
|
{
|
||||||
void *ptr;
|
void *ptr;
|
||||||
ptr = mmap(NULL, size, PROT_READ|PROT_WRITE,
|
ptr = mmap(NULL, size, PROT_READ|PROT_WRITE,
|
||||||
|
@ -158,20 +159,20 @@ _PyObject_ArenaMmap(void *ctx, size_t size)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_PyObject_ArenaMunmap(void *ctx, void *ptr, size_t size)
|
_PyObject_ArenaMunmap(void *Py_UNUSED(ctx), void *ptr, size_t size)
|
||||||
{
|
{
|
||||||
munmap(ptr, size);
|
munmap(ptr, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
static void *
|
static void *
|
||||||
_PyObject_ArenaMalloc(void *ctx, size_t size)
|
_PyObject_ArenaMalloc(void *Py_UNUSED(ctx), size_t size)
|
||||||
{
|
{
|
||||||
return malloc(size);
|
return malloc(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_PyObject_ArenaFree(void *ctx, void *ptr, size_t size)
|
_PyObject_ArenaFree(void *Py_UNUSED(ctx), void *ptr, size_t Py_UNUSED(size))
|
||||||
{
|
{
|
||||||
free(ptr);
|
free(ptr);
|
||||||
}
|
}
|
||||||
|
@ -1684,7 +1685,7 @@ new_arena(void)
|
||||||
pymalloc. When the radix tree is used, 'poolp' is unused.
|
pymalloc. When the radix tree is used, 'poolp' is unused.
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
address_in_range(void *p, poolp pool)
|
address_in_range(void *p, poolp Py_UNUSED(pool))
|
||||||
{
|
{
|
||||||
return arena_map_is_used(p);
|
return arena_map_is_used(p);
|
||||||
}
|
}
|
||||||
|
@ -1945,7 +1946,7 @@ allocate_from_new_pool(uint size)
|
||||||
or when the max memory limit has been reached.
|
or when the max memory limit has been reached.
|
||||||
*/
|
*/
|
||||||
static inline void*
|
static inline void*
|
||||||
pymalloc_alloc(void *ctx, size_t nbytes)
|
pymalloc_alloc(void *Py_UNUSED(ctx), size_t nbytes)
|
||||||
{
|
{
|
||||||
#ifdef WITH_VALGRIND
|
#ifdef WITH_VALGRIND
|
||||||
if (UNLIKELY(running_on_valgrind == -1)) {
|
if (UNLIKELY(running_on_valgrind == -1)) {
|
||||||
|
@ -2215,7 +2216,7 @@ insert_to_freepool(poolp pool)
|
||||||
Return 1 if it was freed.
|
Return 1 if it was freed.
|
||||||
Return 0 if the block was not allocated by pymalloc_alloc(). */
|
Return 0 if the block was not allocated by pymalloc_alloc(). */
|
||||||
static inline int
|
static inline int
|
||||||
pymalloc_free(void *ctx, void *p)
|
pymalloc_free(void *Py_UNUSED(ctx), void *p)
|
||||||
{
|
{
|
||||||
assert(p != NULL);
|
assert(p != NULL);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue