FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.10] bpo-42972: Fully support GC for mmap heap types (GH-26373) by miss-islington · Pull Request #26407 · python/cpython · GitHub

/ cpython Public
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
13 changes: 10 additions & 3 deletions Modules/mmapmodule.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,18 @@ get_mmap_state(PyObject *module)
return state;
}

static int
mmap_object_traverse(mmap_object *m_obj, visitproc visit, void *arg)
{
Py_VISIT(Py_TYPE(m_obj));
return 0;
}

static void
mmap_object_dealloc(mmap_object *m_obj)
{
PyTypeObject *tp = Py_TYPE(m_obj);
PyObject_GC_UnTrack(m_obj);

#ifdef MS_WINDOWS
Py_BEGIN_ALLOW_THREADS
Expand Down Expand Up @@ -1085,15 +1093,14 @@ To map anonymous memory, pass -1 as the fileno (both versions).");

static PyType_Slot mmap_object_slots[] = {
{Py_tp_new, new_mmap_object},
{Py_tp_alloc, PyType_GenericAlloc},
{Py_tp_dealloc, mmap_object_dealloc},
{Py_tp_free, PyObject_Del},
{Py_tp_repr, mmap__repr__method},
{Py_tp_doc, (void *)mmap_doc},
{Py_tp_methods, mmap_object_methods},
{Py_tp_members, mmap_object_members},
{Py_tp_getset, mmap_object_getset},
{Py_tp_getattro, PyObject_GenericGetAttr},
{Py_tp_traverse, mmap_object_traverse},

/* as sequence */
{Py_sq_length, mmap_length},
Expand All @@ -1114,7 +1121,7 @@ static PyType_Slot mmap_object_slots[] = {
static PyType_Spec mmap_object_spec = {
.name = "mmap.mmap",
.basicsize = sizeof(mmap_object),
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC),
.slots = mmap_object_slots,
};

Expand Down

Back | FazBrowse Home | New Git URL