8000 bpo-1635741: port blake2 module to multi-phase init by koubaa · Pull Request #21856 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-1635741: port blake2 module to multi-phase init #21856

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 11 commits into from
Sep 2, 2020
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
Prev Previous commit
Next Next commit
add traverse, clear, and free slots
  • Loading branch information
koubaa committed Aug 28, 2020
commit 4b2e87f5d147f7652d5890404690fa69b7649be8
29 changes: 28 additions & 1 deletion Modules/_blake2/blake2module.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,30 @@ static struct PyMethodDef blake2mod_functions[] = {
{NULL, NULL}
};

static int
_blake2_traverse(PyObject *module, visitproc visit, void *arg)
{
Blake2State *state = blake2_get_state(module);
Py_VISIT(state->blake2b_type);
Py_VISIT(state->blake2s_type);
return 0;
}

static int
_blake2_clear(PyObject *module)
{
Blake2State *state = blake2_get_state(module);
Py_CLEAR(state->blake2b_type);
Py_CLEAR(state->blake2s_type);
return 0;
}

static void
_blake2_free(void *module)
{
_blake2_clear((PyObject *)module);
}

#define ADD_INT(d, name, value) do { \
PyObject *x = PyLong_FromLong(value); \
if (!x) { \
Expand Down Expand Up @@ -109,7 +133,10 @@ static struct PyModuleDef blake2_module = {
.m_doc = blake2mod__doc__,
.m_size = sizeof(Blake2State),
.m_methods = blake2mod_functions,
.m_slots = _blake2_slots
.m_slots = _blake2_slots,
.traverse = _blake2_traverse,
.clear = __blake2_clear,
.free = _blake2_free,
};

PyMODINIT_FUNC
Expand Down
0