8000 Use libgit2 allocator · libgit2/pygit2@053637c · GitHub
[go: up one dir, main page]

Skip to content

Commit 053637c

Browse files
committed
Use libgit2 allocator
1 parent daa8f2a commit 053637c

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

src/odb_backend.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,7 @@ pygit2_odb_backend_read(void **ptr, size_t *sz,
8585
if (!PyArg_ParseTuple(result, "ny#", type, &bytes, sz) || !bytes)
8686
return GIT_EUSER;
8787

88-
/* XXX: This assumes the default libgit2 allocator is in use and will
89-
* probably segfault and/or destroy the universe otherwise */
90-
*ptr = malloc(*sz);
88+
*ptr = git_odb_backend_data_alloc(_be, *sz);
9189
if (!*ptr)
9290
return GIT_EUSER;
9391

@@ -121,9 +119,7 @@ pygit2_odb_backend_read_prefix(git_oid *oid_out, void **ptr, size_t *sz,
121119
&py_oid_out, type, &bytes, sz) || !bytes)
122120
return GIT_EUSER;
123121

124-
/* XXX: This assumes the default libgit2 allocator is in use and will
125-
* probably segfault and/or destroy the universe otherwise */
126-
*ptr = malloc(*sz);
122+
*ptr = git_odb_backend_data_alloc(_be, *sz);
127123
if (!*ptr)
128124
return GIT_EUSER;
129125

@@ -486,9 +482,7 @@ OdbBackend_read(OdbBackend *self, PyObject *py_hex)
486482

487483
tuple = Py_BuildValue("(ny#)", type, data, sz);
488484

489-
/* XXX: This assumes the default libgit2 allocator is in use and will
490-
* probably segfault and/or destroy the universe otherwise */
491-
free(data);
485+
git_odb_backend_data_free(self->odb_backend, data);
492486

493487
return tuple;
494488
}
@@ -527,9 +521,7 @@ OdbBackend_read_prefix(OdbBackend *self, PyObject *py_hex)
527521
py_oid_out = git_oid_to_python(&oid_out);
528522
tuple = Py_BuildValue("(ny#O)", type, data, sz, py_oid_out);
529523

530-
/* XXX: This assumes the default libgit2 allocator is in use and will
531-
* probably segfault and/or destroy the universe otherwise */
532-
free(data);
524+
git_odb_backend_data_free(self->odb_backend, data);
533525

534526
return tuple;
535527
}

0 commit comments

Comments
 (0)
0