Blob Blame History Raw
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>ne_buffer_destroy</title><link rel="stylesheet" type="text/css" href="../manual.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="neon HTTP/WebDAV client library"><link rel="up" href="ref.html" title="neon API reference"><link rel="prev" href="refbufcr.html" title="ne_buffer_create"><link rel="next" href="referr.html" title="ne_get_error"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">ne_buffer_destroy</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="refbufcr.html">Prev</a> </td><th width="60%" align="center">neon API reference</th><td width="20%" align="right"> <a accesskey="n" href="referr.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="refbufdest"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ne_buffer_destroy, ne_buffer_finish — destroy a buffer object</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include &lt;ne_string.h&gt;</pre><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">void <b class="fsfunc">ne_buffer_destroy</b>(</code></td><td>ne_buffer *<var class="pdparam">buf</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">char *<b class="fsfunc">ne_buffer_finish</b>(</code></td><td>ne_buffer *<var class="pdparam">buf</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1"><a name="idm139901960136704"></a><h2>Description</h2><p><code class="function">ne_buffer_destroy</code> frees all memory
associated with the buffer.  <code class="function">ne_buffer_finish</code>
frees the buffer structure, but not the actual string stored in the
buffer, which is returned and must be <code class="function">free</code>()d by
the caller.</p><p>Any use of the buffer object after calling either of these
functions gives undefined behaviour.</p></div><div class="refsect1"><a name="idm139901960133184"></a><h2>Return value</h2><p><code class="function">ne_buffer_finish</code> returns the
<code class="function">malloc</code>-allocated string stored in the buffer.</p></div><div class="refsect1"><a name="idm139901960130912"></a><h2>Examples</h2><p>An example use of <code class="function">ne_buffer_finish</code>;
the <code class="function">duplicate</code> function returns a string made up of 
<code class="parameter">n</code> copies of <code class="parameter">str</code>:</p><pre class="programlisting">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);
}</pre></div><div class="refsect1"><a name="idm139901960126448"></a><h2>See also</h2><p><a class="xref" href="refbuf.html#ne_buffer">ne_buffer</a>, <a class="xref" href="refbufcr.html#ne_buffer_create">ne_buffer_create</a>,
<a class="xref" href="refbufapp.html#ne_buffer_zappend">ne_buffer_zappend</a></p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="refbufcr.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ref.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="referr.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">ne_buffer_create </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> ne_get_error</td></tr></table></div></body></html>