gh-93040 Wrap unused parameters in Objects/obmalloc.c with Py_UNUSED (#93175)

This commit is contained in:
oda-gitso 2022-05-25 17:39:06 +07:00 committed by GitHub
parent 5695c0e0a2
commit 9485a0dbdd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 13 deletions

View File

@ -0,0 +1 @@
Wraps unused parameters in ``Objects/obmalloc.c`` with ``Py_UNUSED``.

View File

@ -90,7 +90,7 @@ struct _PyTraceMalloc_Config _Py_tracemalloc_config = _PyTraceMalloc_Config_INIT
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
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 *
_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
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 *
_PyMem_RawRealloc(void *ctx, void *ptr, size_t size)
_PyMem_RawRealloc(void *Py_UNUSED(ctx), void *ptr, size_t size)
{
if (size == 0)
size = 1;
@ -124,7 +124,7 @@ _PyMem_RawRealloc(void *ctx, void *ptr, size_t size)
}
static void
_PyMem_RawFree(void *ctx, void *ptr)
_PyMem_RawFree(void *Py_UNUSED(ctx), void *ptr)
{
free(ptr);
}
@ -132,21 +132,22 @@ _PyMem_RawFree(void *ctx, void *ptr)
#ifdef MS_WINDOWS
static void *
_PyObject_ArenaVirtualAlloc(void *ctx, size_t size)
_PyObject_ArenaVirtualAlloc(void *Py_UNUSED(ctx), size_t size)
{
return VirtualAlloc(NULL, size,
MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
}
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);
}
#elif defined(ARENAS_USE_MMAP)
static void *
_PyObject_ArenaMmap(void *ctx, size_t size)
_PyObject_ArenaMmap(void *Py_UNUSED(ctx), size_t size)
{
void *ptr;
ptr = mmap(NULL, size, PROT_READ|PROT_WRITE,
@ -158,20 +159,20 @@ _PyObject_ArenaMmap(void *ctx, size_t size)
}
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);
}
#else
static void *
_PyObject_ArenaMalloc(void *ctx, size_t size)
_PyObject_ArenaMalloc(void *Py_UNUSED(ctx), size_t size)
{
return malloc(size);
}
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);
}
@ -1684,7 +1685,7 @@ new_arena(void)
pymalloc. When the radix tree is used, 'poolp' is unused.
*/
static bool
address_in_range(void *p, poolp pool)
address_in_range(void *p, poolp Py_UNUSED(pool))
{
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.
*/
static inline void*
pymalloc_alloc(void *ctx, size_t nbytes)
pymalloc_alloc(void *Py_UNUSED(ctx), size_t nbytes)
{
#ifdef WITH_VALGRIND
if (UNLIKELY(running_on_valgrind == -1)) {
@ -2215,7 +2216,7 @@ insert_to_freepool(poolp pool)
Return 1 if it was freed.
Return 0 if the block was not allocated by pymalloc_alloc(). */
static inline int
pymalloc_free(void *ctx, void *p)
pymalloc_free(void *Py_UNUSED(ctx), void *p)
{
assert(p != NULL);