---
name: "bson_sized_new"
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_sized_new"
---

# bson\_sized\_new(3)

## SYNOPSIS

```
bson_t *
bson_sized_new (size_t size);
```

## PARAMETERS

- •

  **size**: The size to pre-allocate for the underlying buffer.

## DESCRIPTION

The *bson\_sized\_new()* function shall create a new *bson\_t* on the heap with a preallocated buffer. This is useful if you have a good idea of the size of the resulting document.

## RETURNS

A newly allocated *bson\_t* that should be freed with *bson\_destroy()*.

## AUTHOR

MongoDB, Inc

## COPYRIGHT

2009-present, MongoDB, Inc.
