8000 gh-134160: Use PyModuleDef.m_free in the example module xxlimited by encukou · Pull Request #135174 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content
/ cpython Public
< 8000 /div>

gh-134160: Use PyModuleDef.m_free in the example module xxlimited #135174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 6, 2025
Merged
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
Next Next commit
Use PyModuleDef.m_free in the example module xxlimited
  • Loading branch information
encukou committed Jun 5, 2025
commit 500d570c1765eeaa6ee8cba7d2af55031dfaab8c
10 changes: 7 additions & 3 deletions Modules/xxlimited.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,12 @@ xx_clear(PyObject *module)
return 0;
}

static void
xx_free(void *module)
{
(void)xx_clear((PyObject *)module);
}

static struct PyModuleDef xxmodule = {
PyModuleDef_HEAD_INIT,
.m_name = "xxlimited",
Expand All @@ -433,9 +439,7 @@ static struct PyModuleDef xxmodule = {
.m_slots = xx_slots,
.m_traverse = xx_traverse,
.m_clear = xx_clear,
/* m_free is not necessary here: xx_clear clears all references,
* and the module state is deallocated along with the module.
*/
.m_free = xx_free,
};


Expand Down
Loading
0