Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix index mapping
  • Loading branch information
iritkatriel committed Feb 6, 2023
commit 2e2a8614a8681df56186170f0b76b4058754e045
4 changes: 2 additions & 2 deletions Include/internal/pycore_interp.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ PyAPI_FUNC(int) _PyInterpreterState_IDIncref(PyInterpreterState *);
PyAPI_FUNC(void) _PyInterpreterState_IDDecref(PyInterpreterState *);

#define FREELIST_QUANTUM (2*sizeof(void*))
#define SIZE_TO_FREELIST_INDEX(size) ((size-4)/FREELIST_QUANTUM)
#define FREELIST_INDEX_TO_SIZE(idx) (FREELIST_QUANTUM*(idx) + 4)
#define SIZE_TO_FREELIST_INDEX(size) (((size) + FREELIST_QUANTUM - 1)/FREELIST_QUANTUM)
#define FREELIST_INDEX_TO_ALLOCATED_SIZE(idx) ((idx) * FREELIST_QUANTUM)

static inline PyObject*
_PyInterpreterState_FreelistAlloc(PyInterpreterState *interp, Py_ssize_t size) {
Expand Down
2 changes: 1 addition & 1 deletion Python/pystate.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ PyInterpreterState_New(void)
#if WITH_FREELISTS
for (int i=0; i < INTERP_NUM_FREELISTS; i++) {
_PyFreeList_Init(&interp->freelists[i],
FREELIST_INDEX_TO_SIZE(i),
FREELIST_INDEX_TO_ALLOCATED_SIZE(i),
SMALL_OBJECT_FREELIST_SIZE);
}
#endif
Comment thread
iritkatriel marked this conversation as resolved.
Outdated
Expand Down