Skip to content
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
Address review: implement CLEAR_CALLBACK_CONTEXT as a regular function
  • Loading branch information
Erlend E. Aasland committed Sep 1, 2021
commit 83ab097a05e1191e35453aaad3b168a8dc4f4666
20 changes: 10 additions & 10 deletions Modules/_sqlite/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,13 @@ connection_traverse(pysqlite_Connection *self, visitproc visit, void *arg)
return 0;
}

#define CLEAR_CALLBACK_CONTEXT(ctx) \
do { \
if (ctx) { \
Py_CLEAR(ctx->callable); \
} \
} while (0)
static inline void
clear_callback_context(callback_context *ctx)
{
if (ctx != NULL) {
Py_CLEAR(ctx->callable);
}
}

static int
connection_clear(pysqlite_Connection *self)
Expand All @@ -263,10 +264,9 @@ connection_clear(pysqlite_Connection *self)
Py_CLEAR(self->cursors);
Py_CLEAR(self->row_factory);
Py_CLEAR(self->text_factory);
CLEAR_CALLBACK_CONTEXT(self->trace_ctx);
CLEAR_CALLBACK_CONTEXT(self->progress_ctx);
CLEAR_CALLBACK_CONTEXT(self->authorizer_ctx);
#undef CLEAR_CALLBACK_CONTEXT
clear_callback_context(self->trace_ctx);
clear_callback_context(self->progress_ctx);
clear_callback_context(self->authorizer_ctx);
return 0;
}

Expand Down