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

Function PyBytesWriter_Create

asyncpg/protocol/record/pythoncapi_compat.h:2392–2417  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2390}
2391
2392static inline PyBytesWriter*
2393PyBytesWriter_Create(Py_ssize_t size)
2394{
2395 if (size < 0) {
2396 PyErr_SetString(PyExc_ValueError, "size must be >= 0");
2397 return NULL;
2398 }
2399
2400 PyBytesWriter *writer = (PyBytesWriter*)PyMem_Malloc(sizeof(PyBytesWriter));
2401 if (writer == NULL) {
2402 PyErr_NoMemory();
2403 return NULL;
2404 }
2405
2406 writer->obj = NULL;
2407 writer->size = 0;
2408
2409 if (size >= 1) {
2410 if (_PyBytesWriter_Resize_impl(writer, size, 0) < 0) {
2411 PyBytesWriter_Discard(writer);
2412 return NULL;
2413 }
2414 writer->size = size;
2415 }
2416 return writer;
2417}
2418
2419static inline PyObject*
2420PyBytesWriter_FinishWithSize(PyBytesWriter *writer, Py_ssize_t size)

Callers

nothing calls this directly

Calls 2

PyBytesWriter_DiscardFunction · 0.85

Tested by

no test coverage detected