| 57 | } pgit_odb_backend; |
| 58 | |
| 59 | static int |
| 60 | pgit_odb_backend_read(void **ptr, size_t *sz, git_object_t *type, |
| 61 | git_odb_backend *_be, const git_oid *oid) |
| 62 | { |
| 63 | pgit_odb_backend *be = (pgit_odb_backend *)_be; |
| 64 | |
| 65 | PyObject *py_oid = git_oid_to_python(oid); |
| 66 | if (py_oid == NULL) |
| 67 | return GIT_EUSER; |
| 68 | |
| 69 | PyObject *result = PyObject_CallMethod(be->py_backend, "read_cb", "N", py_oid); |
| 70 | if (result == NULL) |
| 71 | return git_error_for_exc(); |
| 72 | |
| 73 | const char *bytes; |
| 74 | Py_ssize_t type_value; |
| 75 | Py_ssize_t py_sz; |
| 76 | if (!PyArg_ParseTuple(result, "ny#", &type_value, &bytes, &py_sz) || !bytes) { |
| 77 | Py_DECREF(result); |
| 78 | return GIT_EUSER; |
| 79 | } |
| 80 | *type = (git_object_t)type_value; |
| 81 | *sz = (size_t)py_sz; |
| 82 | |
| 83 | *ptr = git_odb_backend_data_alloc(_be, *sz); |
| 84 | if (!*ptr) { |
| 85 | Py_DECREF(result); |
| 86 | return GIT_EUSER; |
| 87 | } |
| 88 | |
| 89 | memcpy(*ptr, bytes, *sz); |
| 90 | Py_DECREF(result); |
| 91 | return 0; |
| 92 | } |
| 93 | |
| 94 | static int |
| 95 | pgit_odb_backend_read_prefix(git_oid *oid_out, void **ptr, size_t *sz, git_object_t *type, |
nothing calls this directly
no test coverage detected
searching dependent graphs…