| 2508 | } |
| 2509 | |
| 2510 | static inline int |
| 2511 | PyBytesWriter_WriteBytes(PyBytesWriter *writer, |
| 2512 | const void *bytes, Py_ssize_t size) |
| 2513 | { |
| 2514 | if (size < 0) { |
| 2515 | size_t len = strlen((const char*)bytes); |
| 2516 | if (len > (size_t)PY_SSIZE_T_MAX) { |
| 2517 | PyErr_NoMemory(); |
| 2518 | return -1; |
| 2519 | } |
| 2520 | size = (Py_ssize_t)len; |
| 2521 | } |
| 2522 | |
| 2523 | Py_ssize_t pos = writer->size; |
| 2524 | if (PyBytesWriter_Grow(writer, size) < 0) { |
| 2525 | return -1; |
| 2526 | } |
| 2527 | char *buf = (char*)PyBytesWriter_GetData(writer); |
| 2528 | memcpy(buf + pos, bytes, (size_t)size); |
| 2529 | return 0; |
| 2530 | } |
| 2531 | |
| 2532 | static inline int |
| 2533 | PyBytesWriter_Format(PyBytesWriter *writer, const char *format, ...) |
no test coverage detected