---
name: "bson_writer_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_writer_new"
---

# bson\_writer\_new(3)

## SYNOPSIS

```
bson_writer_t *
bson_writer_new (uint8_t **buf,
                 size_t *buflen,
                 size_t offset,
                 bson_realloc_func realloc_func,
                 void *realloc_func_ctx);
```

## PARAMETERS

- •

  **buf**: A uint8\_t.

- •

  **buflen**: A size\_t.

- •

  **offset**: A size\_t.

- •

  **realloc\_func**: A bson\_realloc\_func.

- •

  **realloc\_func\_ctx**: A bson\_realloc\_func.

## DESCRIPTION

Creates a new instance of *bson\_writer\_t* using the **buffer**, **length**, **offset**, and \_realloc()\_ function supplied.

The caller is expected to clean up the structure when finished using *bson\_writer\_destroy()*.

## RETURNS

A newly allocated bson\_writer\_t.

## AUTHOR

MongoDB, Inc

## COPYRIGHT

2009-present, MongoDB, Inc.
