---
name: "bson_aligned_alloc"
section: "3"
platform: "linux"
package: "libbson-doc"
version: "1.30.4-1+deb13u3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/bson_aligned_alloc"
---

# bson\_aligned\_alloc(3)

## SYNOPSIS

```
void *
bson_aligned_alloc (size_t alignment, size_t num_bytes);
```

## PARAMETERS

- •

  **alignment**: The alignment of the allocated bytes of memory. Must be a power of 2 and a multiple of **sizeof (void \*)**.

- •

  **num\_bytes**: The number of bytes to allocate. Must be a multiple of **alignment**.

## DESCRIPTION

This is a portable **aligned\_alloc()** wrapper.

In general, this function will return an allocation at least **sizeof(void\*)** bytes or bigger with an alignment of at least **alignment**.

If there was a failure to allocate **num\_bytes** bytes aligned to **alignment**, the process will be aborted.

**WARNING:**

This function will abort on failure to allocate memory.

## RETURNS

A pointer to a memory region which *HAS NOT* been zeroed.

## AUTHOR

MongoDB, Inc

## COPYRIGHT

2009-present, MongoDB, Inc.
