| 457 | } |
| 458 | |
| 459 | NPY_NO_EXPORT int |
| 460 | npy_amergesort(void *v, npy_intp *tosort, npy_intp num, void *varr) |
| 461 | { |
| 462 | PyArrayObject *arr = (PyArrayObject *)varr; |
| 463 | npy_intp elsize = PyArray_ITEMSIZE(arr); |
| 464 | PyArray_CompareFunc *cmp = PyArray_DESCR(arr)->f->compare; |
| 465 | npy_intp *pl, *pr, *pw; |
| 466 | |
| 467 | /* Items that have zero size don't make sense to sort */ |
| 468 | if (elsize == 0) { |
| 469 | return 0; |
| 470 | } |
| 471 | |
| 472 | pl = tosort; |
| 473 | pr = pl + num; |
| 474 | pw = (npy_intp *)malloc((num >> 1) * sizeof(npy_intp)); |
| 475 | if (pw == NULL) { |
| 476 | return -NPY_ENOMEM; |
| 477 | } |
| 478 | npy_amergesort0(pl, pr, (char *)v, pw, elsize, cmp, arr); |
| 479 | free(pw); |
| 480 | |
| 481 | return 0; |
| 482 | } |
| 483 | |
| 484 | /*************************************** |
| 485 | * C > C++ dispatch |
nothing calls this directly
no test coverage detected