swab(3)

swab3

Swap adjacent bytes

Usage

#include <unistd.h>

void

swab(const void *restrict src, void *restrict dest, ssize_t nbytes);

Library

Standard C Library (libc, -lc)

Overview

The function swab() copies nbytes bytes from the location referenced by src to the location referenced by dest, swapping adjacent bytes.

The argument nbytes should be an even number. If nbytes is odd, swab() copies and exchanges nbytes -1 bytes and the disposition of the last byte is unspecified. If copying takes place between objects that overlap, the behavior is undefined. If nbytes is negative, swab() does nothing.

Releases

163 releases since Mac OS X 10.0; the text changed 4 times.

  1. 10.0–10.1.5
  2. 10.2–10.2.8
  3. 10.3–10.4.11
  4. 10.5–10.6.8
  5. 10.7–26.5

History

A swab() function appeared in Version 7 AT&T UNIX.

From Libc 1752.120.2 in macOS 26.5. Parsed by carta from the page's mdoc source.