---
name: "bson_init_static"
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_init_static"
---

# bson\_init\_static(3)

## SYNOPSIS

```
bool
bson_init_static (bson_t *b, const uint8_t *data, size_t length);
```

## PARAMETERS

- •

  **b**: A *bson\_t*.

- •

  **data**: A buffer to initialize with.

- •

  **length**: The length of **data** in bytes.

## DESCRIPTION

The *bson\_init\_static()* function shall initialize a read-only *bson\_t* on the stack using the data provided. No copies of the data will be made and therefore must remain valid for the lifetime of the *bson\_t*.

The resulting *bson\_t* has internal references and therefore must not be copied to avoid dangling pointers in the copy.

## RETURNS

Returns **true** if *bson\_t* was successfully initialized, otherwise **false**. The function can fail if **data** or **length** are invalid.

## AUTHOR

MongoDB, Inc

## COPYRIGHT

2009-present, MongoDB, Inc.
