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

Function pgit_strdup

src/utils.c:154–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

152
153
154char*
155pgit_strdup(PyObject *value)
156{
157 const char *str;
158 char *copy;
159 size_t len;
160
161 if (PyUnicode_Check(value)) {
162 str = PyUnicode_AsUTF8(value);
163 if (str == NULL)
164 return NULL;
165 len = strlen(str);
166 }
167 else {
168 Error_type_error("unexpected %.200s", value);
169 return NULL;
170 }
171
172 copy = malloc(len + 1);
173 if (copy == NULL) {
174 PyErr_NoMemory();
175 return NULL;
176 }
177
178 memcpy(copy, str, len + 1);
179 return copy;
180}
181
182
183static git_otype

Callers 1

filter_registerFunction · 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…