| 1368 | } |
| 1369 | |
| 1370 | static 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 | |
| 1395 | static inline PyObject* PyUnicodeWriter_Finish(PyUnicodeWriter *writer) |
| 1396 | { |
no test coverage detected