MCPcopy Create free account
hub / github.com/libgit2/pygit2 / pgit_borrow

Function pgit_borrow

src/utils.c:139–151  ·  view source on GitHub ↗

* Return a borrowed c string with the representation of the given Unicode or * Bytes object: * - If value is Unicode return the UTF-8 representation * - If value is Bytes return the raw sttring * In both cases the returned string is owned by value and must not be * modified, nor freed. */

Source from the content-addressed store, hash-verified

137 * modified, nor freed.
138 */
139const char*
140pgit_borrow(PyObject *value)
141{
142 if (PyUnicode_Check(value)) { // Text string
143 return PyUnicode_AsUTF8(value);
144 } else if (PyBytes_Check(value)) { // Byte string
145 return PyBytes_AsString(value);
146 }
147
148 // Type error
149 Error_type_error("unexpected %.200s", value);
150 return NULL;
151}
152
153
154char*

Callers 6

reference_is_valid_nameFunction · 0.85
Repository_revparse_extFunction · 0.85
Repository_revparseFunction · 0.85
Diff_parse_diffFunction · 0.85

Calls 1

Error_type_errorFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…