memalignment(3)

memalignment3

Find the memory alignment of an object

Usage

Standard C Library (libc, -lc)

#include <stdlib.h>

size_t

memalignment(const void *ptr);

Overview

The memalignment() function determines the alignment of the object pointed to by ptr. This alignment is a power of 2, and may be larger than the range supported by the alignof operator. The value returned can be compared to the result of alignof, and if it is greater or equal, the alignment requirement of the operand is satisfied.

Return values

Returns the alignment of ptr as a power of 2. If ptr is a null pointer, an alignment of zero is returned. An alignment of zero indicates that the tested pointer cannot be used to access an object of any type.

Releases

2 releases since FreeBSD 15.1-RELEASE; the text changed 1 time.

  1. 15.1
  2. 16.0

Standards

The memalignment() function conforms to ISO/IEC 9899:2024 (“ISO C23”).

History

The memalignment() function was added in FreeBSD 15.1.

Authors

Robert Clausecker ⟨[email protected]⟩

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.