---
name: "ne_buffer_destroy"
section: "3"
platform: "linux"
package: "neon"
version: "0.37.1-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/ne_buffer_destroy"
---

# ne\_buffer\_destroy(3)

destroy a buffer object

## NAME

ne\_buffer\_destroy, ne\_buffer\_finish - destroy a buffer object

## SYNOPSIS

```
#include <ne_string.h>
```

**void ne\_buffer\_destroy(ne\_buffer \****buf***);**

**char \*ne\_buffer\_finish(ne\_buffer \****buf***);**

## DESCRIPTION

**ne\_buffer\_destroy** frees all memory associated with the buffer. **ne\_buffer\_finish** frees the buffer structure, but not the actual string stored in the buffer, which is returned and must be **free**()d by the caller.

Any use of the buffer object after calling either of these functions gives undefined behaviour.

## RETURN VALUE

**ne\_buffer\_finish** returns the **malloc**-allocated string stored in the buffer.

## EXAMPLES

An example use of **ne\_buffer\_finish**; the **duplicate** function returns a string made up of *n* copies of *str*:

```
static char *duplicate(int n, const char *str)
{
  ne_buffer *buf = ne_buffer_create();
  while (n--) {
    ne_buffer_zappend(buf, str);
  }
  return ne_buffer_finish(buf);
}
```

## SEE ALSO

[**ne\_buffer**(3)](/ne_buffer/3.md), [**ne\_buffer\_create**(3)](/ne_buffer_create/3.md), [**ne\_buffer\_zappend**(3)](/ne_buffer_zappend/3.md)

## COPYRIGHT

Copyright © 2001-2026 Joe Orton\
