NE_BUFFER_DESTROY(3)
β¨ NE_BUFFER_DESTROY(3) β¨
okay bestie, so this is the neon API reference for NE_BUFFER_DESTROY(3) β yes the title is literally the same as the function, main character energy fr π
πΈ NAME πΈ
ne_buffer_destroy, ne_buffer_finish β the two functions that let a buffer object go. it's giving "closure era" π¦
π SYNOPSIS π
#include <ne_string.h>
void ne_buffer_destroy(ne_buffer *buf);
char *ne_buffer_finish(ne_buffer *buf);
π DESCRIPTION π
so, two ways to say goodbye to your buffer, and they are not the same, okay? listen up π
ne_buffer_destroy frees all memory associated with the buffer. all of it. the whole thing. bye π
ne_buffer_finish is the sneaky one β it frees the buffer structure, but not the actual string stored in the buffer. that string gets returned to you, and you have to free() it yourself. not me, not the library. you. no cap π«Ά
β οΈ okay this is the important part: any use of the buffer object after calling either of these functions gives undefined behaviour. undefined behaviour is not a vibe. do not touch the buffer after it's gone. periodt. π
β RETURN VALUE β
ne_buffer_finish returns the malloc-allocated string stored in the buffer. that's your string now, bestie β treat it right, and free() it when you're done π
π EXAMPLES π
here's an example use of ne_buffer_finish β the duplicate function returns a string made up of n copies of str. iconic, honestly:
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 how it returns straight from ne_buffer_finish? the string lives on, the buffer structure is gone, and the caller handles the free(). slay β¨
π¦ SEE ALSO π¦
go read those too, iykwyk π
π COPYRIGHT π
Copyright Β© 2001-2026 Joe Orton
and that's the whole page, bestie!! this one dropped on 03/20/2026 with the neon source/version β so go forth, destroy and finish your buffers responsibly, and remember: don't touch anything after it's freed π
πβ
π¦ where this page comes from
- arch rolling: neon 0.37.1-1 Β· LGPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms