| 309 | |
| 310 | |
| 311 | NPY_NO_EXPORT int |
| 312 | npy_to_unicode(PyArray_Descr *descr, |
| 313 | const Py_UCS4 *str, const Py_UCS4 *end, char *dataptr, |
| 314 | parser_config *NPY_UNUSED(unused)) |
| 315 | { |
| 316 | int length = descr->elsize / 4; |
| 317 | |
| 318 | if (length <= end - str) { |
| 319 | memcpy(dataptr, str, length * 4); |
| 320 | } |
| 321 | else { |
| 322 | size_t given_len = end - str; |
| 323 | memcpy(dataptr, str, given_len * 4); |
| 324 | memset(dataptr + given_len * 4, '\0', (length - given_len) * 4); |
| 325 | } |
| 326 | |
| 327 | if (!PyArray_ISNBO(descr->byteorder)) { |
| 328 | for (int i = 0; i < length; i++) { |
| 329 | npy_bswap4_unaligned(dataptr); |
| 330 | dataptr += 4; |
| 331 | } |
| 332 | } |
| 333 | return 0; |
| 334 | } |
| 335 | |
| 336 | |
| 337 |
nothing calls this directly
no test coverage detected