f_memcpy_bytes ============== Copy raw storage between two scalar buffer starts, with an explicit **byte** count, without numerical or character-code conversion. .. code-block:: fortran use futile ! or: use f_memcpy_module, only: f_memcpy_bytes Signature --------- Generated from the FYPP documentation stub ``doc/generated/f_memcpy_doc.f90`` (emitted by ``fypp/memcpy-doc.fypp`` from the same loops as ``flib/f_memcpy.f90``). In the signature, ``any_intrinsic`` is a documentation placeholder: the argument may be of any intrinsic type, of any Futile :ref:`ABI kind `. The supported combinations are listed under `Supported kinds`_. .. f:autointerface:: f_memcpy_bytes Typical call ------------ .. code-block:: fortran call f_memcpy_bytes(dest=buffer(first), src=value, nbytes=f_sizeof(value)) Supported kinds --------------- .. fortran-specifics:: f_memcpy_bytes :args: dest, src Notes ----- .. rubric:: When to prefer it over ``f_memcpy`` Use :doc:`f_memcpy` whenever the count is a whole number of source elements: it checks known array capacities. ``f_memcpy_bytes`` is the escape hatch for byte-level transfers, including partial source elements and arbitrary type/kind pairs, where no capacity is known. .. rubric:: Capacity, overlap and zero bytes Both arguments are scalar starts of larger contiguous buffers; the caller guarantees that ``nbytes`` fits in both. The copy uses C ``memmove``, so partial overlap is safe. A zero-byte copy obtains no address. .. rubric:: Errors A negative ``nbytes``, or a positive transfer from or to zero-width scalar storage, raises ``ERR_INVALID_COPY`` without changing the destination. Examples -------- Compiled and run by CI (``tests/flib/memcpy_check.f90``). The complex scalar ``z`` is copied into the middle of a real array, byte for byte: .. fortranliteral:: tests/flib/memcpy_check.f90 :marker: byte_copy :dedent: 2 See also -------- * :doc:`f_memcpy` -- element-count copies with capacity checks for arrays. * :doc:`f_subptr` -- borrowed views to address part of an array as a buffer. * :doc:`f_sizeof` -- payload size in bytes, the usual source of ``nbytes``.