Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9485a0d

Browse files
author
oda-gitso
authored
gh-93040 Wrap unused parameters in Objects/obmalloc.c with Py_UNUSED (#93175)
1 parent 5695c0e commit 9485a0d

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Wraps unused parameters in ``Objects/obmalloc.c`` with ``Py_UNUSED``.

Objects/obmalloc.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ struct _PyTraceMalloc_Config _Py_tracemalloc_config = _PyTraceMalloc_Config_INIT
9090

9191

9292
static void *
93-
_PyMem_RawMalloc(void *ctx, size_t size)
93+
_PyMem_RawMalloc(void *Py_UNUSED(ctx), size_t size)
9494
{
9595
/* PyMem_RawMalloc(0) means malloc(1). Some systems would return NULL
9696
for malloc(0), which would be treated as an error. Some platforms would
@@ -102,7 +102,7 @@ _PyMem_RawMalloc(void *ctx, size_t size)
102102
}
103103

104104
static void *
105-
_PyMem_RawCalloc(void *ctx, size_t nelem, size_t elsize)
105+
_PyMem_RawCalloc(void *Py_UNUSED(ctx), size_t nelem, size_t elsize)
106106
{
107107
/* PyMem_RawCalloc(0, 0) means calloc(1, 1). Some systems would return NULL
108108
for calloc(0, 0), which would be treated as an error. Some platforms
@@ -116,37 +116,38 @@ _PyMem_RawCalloc(void *ctx, size_t nelem, size_t elsize)
116116
}
117117

118118
static void *
119-
_PyMem_RawRealloc(void *ctx, void *ptr, size_t size)
119+
_PyMem_RawRealloc(void *Py_UNUSED(ctx), void *ptr, size_t size)
120120
{
121121
if (size == 0)
122122
size = 1;
123123
return realloc(ptr, size);
124124
}
125125

126126
static void
127-
_PyMem_RawFree(void *ctx, void *ptr)
127+
_PyMem_RawFree(void *Py_UNUSED(ctx), void *ptr)
128128
{
129129
free(ptr);
130130
}
131131

132132

133133
#ifdef MS_WINDOWS
134134
static void *
135-
_PyObject_ArenaVirtualAlloc(void *ctx, size_t size)
135+
_PyObject_ArenaVirtualAlloc(void *Py_UNUSED(ctx), size_t size)
136136
{
137137
return VirtualAlloc(NULL, size,
138138
MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
139139
}
140140

141141
static void
142-
_PyObject_ArenaVirtualFree(void *ctx, void *ptr, size_t size)
142+
_PyObject_ArenaVirtualFree(void *Py_UNUSED(ctx), void *ptr,
143+
size_t Py_UNUSED(size))
143144
{
144145
VirtualFree(ptr, 0, MEM_RELEASE);
145146
}
146147

147148
#elif defined(ARENAS_USE_MMAP)
148149
static void *
149-
_PyObject_ArenaMmap(void *ctx, size_t size)
150+
_PyObject_ArenaMmap(void *Py_UNUSED(ctx), size_t size)
150151
{
151152
void *ptr;
152153
ptr = mmap(NULL, size, PROT_READ|PROT_WRITE,
@@ -158,20 +159,20 @@ _PyObject_ArenaMmap(void *ctx, size_t size)
158159
}
159160

160161
static void
161-
_PyObject_ArenaMunmap(void *ctx, void *ptr, size_t size)
162+
_PyObject_ArenaMunmap(void *Py_UNUSED(ctx), void *ptr, size_t size)
162163
{
163164
munmap(ptr, size);
164165
}
165166

166167
#else
167168
static void *
168-
_PyObject_ArenaMalloc(void *ctx, size_t size)
169+
_PyObject_ArenaMalloc(void *Py_UNUSED(ctx), size_t size)
169170
{
170171
return malloc(size);
171172
}
172173

173174
static void
174-
_PyObject_ArenaFree(void *ctx, void *ptr, size_t size)
175+
_PyObject_ArenaFree(void *Py_UNUSED(ctx), void *ptr, size_t Py_UNUSED(size))
175176
{
176177
free(ptr);
177178
}
@@ -1684,7 +1685,7 @@ new_arena(void)
16841685
pymalloc. When the radix tree is used, 'poolp' is unused.
16851686
*/
16861687
static bool
1687-
address_in_range(void *p, poolp pool)
1688+
address_in_range(void *p, poolp Py_UNUSED(pool))
16881689
{
16891690
return arena_map_is_used(p);
16901691
}
@@ -1945,7 +1946,7 @@ allocate_from_new_pool(uint size)
19451946
or when the max memory limit has been reached.
19461947
*/
19471948
static inline void*
1948-
pymalloc_alloc(void *ctx, size_t nbytes)
1949+
pymalloc_alloc(void *Py_UNUSED(ctx), size_t nbytes)
19491950
{
19501951
#ifdef WITH_VALGRIND
19511952
if (UNLIKELY(running_on_valgrind == -1)) {
@@ -2215,7 +2216,7 @@ insert_to_freepool(poolp pool)
22152216
Return 1 if it was freed.
22162217
Return 0 if the block was not allocated by pymalloc_alloc(). */
22172218
static inline int
2218-
pymalloc_free(void *ctx, void *p)
2219+
pymalloc_free(void *Py_UNUSED(ctx), void *p)
22192220
{
22202221
assert(p != NULL);
22212222

0 commit comments

Comments
 (0)