"Fossies" - the Fresh Open Source Software Archive

Member "neon-0.31.2/doc/html/refbufdest.html" (20 Jun 2020, 4032 Bytes) of package /linux/www/neon-0.31.2.tar.gz:


Caution: In this restricted "Fossies" environment the current HTML page may not be correctly presentated and may have some non-functional links. You can here alternatively try to browse the pure source code or just view or download the uninterpreted raw source code. If the rendering is insufficient you may try to find and view the page on the project site itself.

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