MCPcopy Create free account
hub / github.com/MagicStack/asyncpg / PyUnicodeWriter_Create

Function PyUnicodeWriter_Create

asyncpg/protocol/record/pythoncapi_compat.h:1370–1393  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1368}
1369
1370static inline PyUnicodeWriter* PyUnicodeWriter_Create(Py_ssize_t length)
1371{
1372 if (length < 0) {
1373 PyErr_SetString(PyExc_ValueError,
1374 "length must be positive");
1375 return NULL;
1376 }
1377
1378 const size_t size = sizeof(_PyUnicodeWriter);
1379 PyUnicodeWriter *pub_writer = (PyUnicodeWriter *)PyMem_Malloc(size);
1380 if (pub_writer == _Py_NULL) {
1381 PyErr_NoMemory();
1382 return _Py_NULL;
1383 }
1384 _PyUnicodeWriter *writer = (_PyUnicodeWriter *)pub_writer;
1385
1386 _PyUnicodeWriter_Init(writer);
1387 if (_PyUnicodeWriter_Prepare(writer, length, 127) < 0) {
1388 PyUnicodeWriter_Discard(pub_writer);
1389 return NULL;
1390 }
1391 writer->overallocate = 1;
1392 return pub_writer;
1393}
1394
1395static inline PyObject* PyUnicodeWriter_Finish(PyUnicodeWriter *writer)
1396{

Callers 1

record_reprFunction · 0.85

Calls 1

PyUnicodeWriter_DiscardFunction · 0.85

Tested by

no test coverage detected