MCPcopy Create free account
hub / github.com/numpy/numpy / copy_and_swap

Function copy_and_swap

numpy/core/src/multiarray/ctors.c:438–460  ·  view source on GitHub ↗

If numitems > 1, then dst must be contiguous */

Source from the content-addressed store, hash-verified

436
437/* If numitems > 1, then dst must be contiguous */
438NPY_NO_EXPORT void
439copy_and_swap(void *dst, void *src, int itemsize, npy_intp numitems,
440 npy_intp srcstrides, int swap)
441{
442 if ((numitems == 1) || (itemsize == srcstrides)) {
443 memcpy(dst, src, itemsize*numitems);
444 }
445 else {
446 npy_intp i;
447 char *s1 = (char *)src;
448 char *d1 = (char *)dst;
449
450 for (i = 0; i < numitems; i++) {
451 memcpy(d1, s1, itemsize);
452 d1 += itemsize;
453 s1 += srcstrides;
454 }
455 }
456
457 if (swap) {
458 byte_swap_vector(dst, numitems, itemsize);
459 }
460}
461
462
463/*

Callers

nothing calls this directly

Calls 1

byte_swap_vectorFunction · 0.85

Tested by

no test coverage detected