# shz_memcpy

Source: https://sh4zam.com/api/memory/shz_memcpy/

```c
SHZ_INLINE void* shz_memcpy( void* SHZ_RESTRICT dst, const void* SHZ_RESTRICT src, size_t bytes) SHZ_NOEXCEPT;
```

Generic drop-in fast memcpy() replacement.

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `dst` | `void *SHZ_RESTRICT` |  |
| `src` | `const void *SHZ_RESTRICT` |  |
| `bytes` | `size_t` |  |

## Returns

`void *`

## Details

Copies `bytes` from `src` to `dst`, determining the most efficient specialization to call into at run-time, returning `dst`.

There are no alignment or size requirements for this routine, but it is specifically optimized for 2-, 4-, 8-, and 32-byte alignments, with bigger alignments bringing bigger gainz.

## Notes

- When you know of and can control the `src` and `dst` alignments and batch sizes, you can micro-optimize by calling into the most specific memcpy() specialization for your given scenario, over just using this generic implementation, which must choose which one to use at run-time.

## Warnings

- `dst` and `src` buffers should not be overlapping.

## Availability

- **C++ equivalent:** [`shz::memcpy`](https://sh4zam.com/api/cpp/#shzmemcpy)
- **Type-generic form:** none
- **Back-ends:** SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation
- **Defined in:** [`sh4zam/shz_mem.h:75`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_mem.h#L75)
- **Module:** [Memory](https://sh4zam.com/api/memory/), section "C stdlib Replacements"

## See also

[`shz_memcpy1`](https://sh4zam.com/api/memory/shz_memcpy1/), [`shz_memcpy2`](https://sh4zam.com/api/memory/shz_memcpy2/), [`shz_memcpy4`](https://sh4zam.com/api/memory/shz_memcpy4/), [`shz_memcpy8`](https://sh4zam.com/api/memory/shz_memcpy8/), [`shz_memcpy32`](https://sh4zam.com/api/memory/shz_memcpy32/), [`shz_memcpy64`](https://sh4zam.com/api/memory/shz_memcpy64/), [`shz_memcpy128`](https://sh4zam.com/api/memory/shz_memcpy128/)
