Skip to content

Commit 885553b

Browse files
committed
Memory review filter_register with Kimi's help
Also define PyMethodDef as static to avoid possible build failures, and add .vimrc
1 parent 555b1f3 commit 885553b

22 files changed

+94
-42
lines changed

.vimrc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
" pygit2 local vimrc - C extension configuration
2+
3+
" Get Python include path dynamically
4+
let s:python_include = system('python3 -c "import sysconfig; print(sysconfig.get_path(''include''))"')[:-2]
5+
6+
" Configure ALE C linters with proper includes
7+
let g:ale_c_cc_options = '-std=c11 -Wall -I' . s:python_include . ' -I/usr/local/include'
8+
let g:ale_c_gcc_options = '-std=c11 -Wall -I' . s:python_include . ' -I/usr/local/include'
9+
let g:ale_c_clang_options = '-std=c11 -Wall -I' . s:python_include . ' -I/usr/local/include'
10+
11+
" If you have libgit2 in a non-standard location, add it:
12+
" let g:ale_c_cc_options .= ' -I/usr/local/include/git2'
13+
14+
" Optional: Explicitly set which linters to use for C
15+
let g:ale_linters = get(g:, 'ale_linters', {})
16+
let g:ale_linters.c = ['cc', 'clangtidy'] " or ['gcc'] if you prefer

src/branch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ Branch_upstream_name__get__(Branch *self)
275275
}
276276

277277

278-
PyMethodDef Branch_methods[] = {
278+
static PyMethodDef Branch_methods[] = {
279279
METHOD(Branch, delete, METH_NOARGS),
280280
METHOD(Branch, is_head, METH_NOARGS),
281281
METHOD(Branch, is_checked_out, METH_NOARGS),

src/diff.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ PyMemberDef DiffFile_members[] = {
236236
{NULL}
237237
};
238238

239-
PyMethodDef DiffFile_methods[] = {
239+
static PyMethodDef DiffFile_methods[] = {
240240
METHOD(DiffFile, from_c, METH_STATIC | METH_O),
241241
{NULL},
242242
};
@@ -914,7 +914,7 @@ DiffStats_dealloc(DiffStats *self)
914914
PyObject_Del(self);
915915
}
916916

917-
PyMethodDef DiffStats_methods[] = {
917+
static PyMethodDef DiffStats_methods[] = {
918918
METHOD(DiffStats, format, METH_VARARGS | METH_KEYWORDS),
919919
{NULL}
920920
};

src/filter.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,9 @@ void pygit2_filter_cleanup(git_filter *self, void *payload)
551551
void pygit2_filter_shutdown(git_filter *self)
552552
{
553553
pygit2_filter *filter = (pygit2_filter *)self;
554+
554555
PyGILState_STATE gil = PyGILState_Ensure();
556+
free((void*)filter->filter.attributes);
555557
Py_DECREF(filter->py_filter_cls);
556558
free(filter);
557559
PyGILState_Release(gil);

src/mailmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ Mailmap_dealloc(Mailmap *self)
188188
}
189189

190190

191-
PyMethodDef Mailmap_methods[] = {
191+
static PyMethodDef Mailmap_methods[] = {
192192
METHOD(Mailmap, add_entry, METH_VARARGS | METH_KEYWORDS),
193193
METHOD(Mailmap, resolve, METH_VARARGS),
194194
METHOD(Mailmap, resolve_signature, METH_VARARGS),

src/note.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Note_dealloc(Note *self)
9999
}
100100

101101

102-
PyMethodDef Note_methods[] = {
102+
static PyMethodDef Note_methods[] = {
103103
METHOD(Note, remove, METH_VARARGS),
104104
{NULL}
105105
};

src/object.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ PyGetSetDef Object_getseters[] = {
302302
{NULL}
303303
};
304304

305-
PyMethodDef Object_methods[] = {
305+
static PyMethodDef Object_methods[] = {
306306
METHOD(Object, read_raw, METH_NOARGS),
307307
METHOD(Object, peel, METH_O),
308308
{NULL}

src/odb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ Odb_add_backend(Odb *self, PyObject *args)
344344
}
345345

346346

347-
PyMethodDef Odb_methods[] = {
347+
static PyMethodDef Odb_methods[] = {
348348
METHOD(Odb, add_disk_alternate, METH_O),
349349
METHOD(Odb, read, METH_O),
350350
METHOD(Odb, read_header, METH_O),

src/odb_backend.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ OdbBackend_refresh(OdbBackend *self)
518518
* - readstream
519519
* - freshen
520520
*/
521-
PyMethodDef OdbBackend_methods[] = {
521+
static PyMethodDef OdbBackend_methods[] = {
522522
METHOD(OdbBackend, read, METH_O),
523523
METHOD(OdbBackend, read_prefix, METH_O),
524524
METHOD(OdbBackend, read_header, METH_O),

src/patch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ Patch_hunks__get__(Patch *self)
235235
}
236236

237237

238-
PyMethodDef Patch_methods[] = {
238+
static PyMethodDef Patch_methods[] = {
239239
{"create_from", (PyCFunction) Patch_create_from,
240240
METH_KEYWORDS | METH_VARARGS | METH_STATIC, Patch_create_from__doc__},
241241
{NULL}

0 commit comments

Comments
 (0)