---
name: "bson_writer_get_length"
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_get_length"
---

# bson\_writer\_get\_length(3)

## SYNOPSIS

```
size_t
bson_writer_get_length (bson_writer_t *writer);
```

## PARAMETERS

- •

  **writer**: A *bson\_writer\_t*.

## DESCRIPTION

Fetches the current length of the content written by the buffer (including the initial offset). This includes a partly written document currently being written.

This is useful if you want to check to see if you've passed a given memory boundary that cannot be sent in a packet. See *bson\_writer\_rollback()* to abort the current document being written.

## RETURNS

The length of the underlying buffer.

## AUTHOR

MongoDB, Inc

## COPYRIGHT

2009-present, MongoDB, Inc.
