---
name: "ne_buffer_finish"
section: "3"
platform: "linux"
package: "libneon27-dev"
version: "0.34.2-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/ne_buffer_destroy"
---

# ne\_buffer\_finish(3)

destroy a buffer object

Part of [ne\_buffer\_destroy(3)](/ne_buffer_destroy/3.md).

## 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, ne\_buffer\_create, ne\_buffer\_zappend

## COPYRIGHT

Copyright © 2001-2024 Joe Orton\
