re04.html 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  5. <title>&lt;GByteArray&gt;: </title>
  6. <meta name="generator" content="DocBook XSL Stylesheets V1.79.2">
  7. <link rel="home" href="index.html" title="">
  8. <link rel="up" href="ch01.html" title="GLib">
  9. <link rel="prev" href="re03.html" title="&lt;%GLibBookmarkFileError&gt;">
  10. <link rel="next" href="re05.html" title="&lt;GBytes&gt;">
  11. <meta name="generator" content="GTK-Doc V1.33.1 (XML mode)">
  12. <link rel="stylesheet" href="style.css" type="text/css">
  13. </head>
  14. <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
  15. <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
  16. <td width="100%" align="left" class="shortcuts"></td>
  17. <td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
  18. <td><img src="up-insensitive.png" width="16" height="16" border="0"></td>
  19. <td><a accesskey="p" href="re03.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
  20. <td><a accesskey="n" href="re05.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
  21. </tr></table>
  22. <div class="refentry">
  23. <a name="id-1.1.5"></a><div class="titlepage"></div>
  24. <div class="refnamediv">
  25. <h2>&lt;GByteArray&gt;</h2>
  26. <p>&lt;GByteArray&gt;</p>
  27. </div>
  28. <div class="refsect1">
  29. <a name="id-1.1.5.2"></a><h2>Description</h2>
  30. <p>Contains the public fields of a GByteArray.</p>
  31. </div>
  32. <div class="refsect1">
  33. <a name="id-1.1.5.3"></a><h2>Functions</h2>
  34. <div class="refsect2">
  35. <a name="id-1.1.5.3.2"></a><h3>byte-array:free</h3>
  36. <div class="informalexample"><pre class="programlisting">(define-values (%return) (byte-array:free array free-segment))
  37. </pre></div>
  38. <p>Frees the memory allocated by the <span class="type">GByteArray</span>. If <em class="parameter"><code>free_segment</code></em> is
  39. <code class="constant">TRUE</code> it frees the actual byte data. If the reference count of
  40. <em class="parameter"><code>array</code></em> is greater than one, the <span class="type">GByteArray</span> wrapper is preserved but
  41. the size of <em class="parameter"><code>array</code></em> will be set to zero.</p>
  42. <div class="refsect3">
  43. <a name="id-1.1.5.3.2.4"></a><h4>Parameters</h4>
  44. <div class="informaltable"><table>
  45. <tr>
  46. <td class="parameter_name"><p>array</p></td>
  47. <td class="parameter_description">
  48. <p>a <span class="type">GByteArray</span></p>
  49. <p>Passed as <code class="code">array</code></p>
  50. </td>
  51. </tr>
  52. <tr>
  53. <td class="parameter_name"><p>free_segment</p></td>
  54. <td class="parameter_description">
  55. <p>if <code class="constant">TRUE</code> the actual byte data is freed as well</p>
  56. <p>Passed as <code class="code">free-segment</code></p>
  57. </td>
  58. </tr>
  59. </table></div>
  60. </div>
  61. </div>
  62. <div class="refsect2">
  63. <a name="id-1.1.5.3.3"></a><h3>byte-array:free-to-bytes</h3>
  64. <div class="informalexample"><pre class="programlisting">(define-values (%return) (byte-array:free-to-bytes array))
  65. </pre></div>
  66. <p>Transfers the data from the <span class="type">GByteArray</span> into a new immutable <span class="type">GBytes</span>.
  67. </p>
  68. <p>The <span class="type">GByteArray</span> is freed unless the reference count of <em class="parameter"><code>array</code></em> is greater
  69. than one, the <span class="type">GByteArray</span> wrapper is preserved but the size of <em class="parameter"><code>array</code></em>
  70. will be set to zero.
  71. </p>
  72. <p>This is identical to using <code class="function">g_bytes_new_take()</code> and <code class="function">g_byte_array_free()</code>
  73. together.</p>
  74. <div class="refsect3">
  75. <a name="id-1.1.5.3.3.6"></a><h4>Parameters</h4>
  76. <div class="informaltable"><table><tr>
  77. <td class="parameter_name"><p>array</p></td>
  78. <td class="parameter_description">
  79. <p>a <span class="type">GByteArray</span></p>
  80. <p>Passed as <code class="code">array</code></p>
  81. </td>
  82. </tr></table></div>
  83. </div>
  84. </div>
  85. <div class="refsect2">
  86. <a name="id-1.1.5.3.4"></a><h3>byte-array:new</h3>
  87. <div class="informalexample"><pre class="programlisting">(define-values (%return) (byte-array:new))
  88. </pre></div>
  89. <p>Creates a new <span class="type">GByteArray</span> with a reference count of 1.</p>
  90. </div>
  91. <div class="refsect2">
  92. <a name="id-1.1.5.3.5"></a><h3>byte-array:new-take</h3>
  93. <div class="informalexample"><pre class="programlisting">(define-values (%return) (byte-array:new-take data))
  94. </pre></div>
  95. <p>Create byte array containing the data. The data will be owned by the array
  96. and will be freed with <code class="function">g_free()</code>, i.e. it could be allocated using <code class="function">g_strdup()</code>.</p>
  97. <div class="refsect3">
  98. <a name="id-1.1.5.3.5.4"></a><h4>Parameters</h4>
  99. <div class="informaltable"><table>
  100. <tr>
  101. <td class="parameter_name"><p>data</p></td>
  102. <td class="parameter_description">
  103. <p>byte data for the array</p>
  104. <p>Passed as <code class="code">data</code></p>
  105. </td>
  106. </tr>
  107. <tr>
  108. <td class="parameter_name"><p>len</p></td>
  109. <td class="parameter_description">
  110. <p>length of <em class="parameter"><code>data</code></em></p>
  111. <p>Inferred from <code class="code">data</code></p>
  112. </td>
  113. </tr>
  114. </table></div>
  115. </div>
  116. </div>
  117. <div class="refsect2">
  118. <a name="id-1.1.5.3.6"></a><h3>byte-array:steal</h3>
  119. <div class="informalexample"><pre class="programlisting">(define-values (%return len) (byte-array:steal array len))
  120. </pre></div>
  121. <p>Frees the data in the array and resets the size to zero, while
  122. the underlying array is preserved for use elsewhere and returned
  123. to the caller.</p>
  124. <div class="refsect3">
  125. <a name="id-1.1.5.3.6.4"></a><h4>Parameters</h4>
  126. <div class="informaltable"><table>
  127. <tr>
  128. <td class="parameter_name"><p>array</p></td>
  129. <td class="parameter_description">
  130. <p>a <span class="type">GByteArray</span>.</p>
  131. <p>Passed as <code class="code">array</code></p>
  132. </td>
  133. </tr>
  134. <tr>
  135. <td class="parameter_name"><p>len</p></td>
  136. <td class="parameter_description">
  137. <p>pointer to retrieve the number of
  138. elements of the original array</p>
  139. <p>Passed as <code class="code">len</code></p>
  140. </td>
  141. </tr>
  142. </table></div>
  143. </div>
  144. </div>
  145. <div class="refsect2">
  146. <a name="id-1.1.5.3.7"></a><h3>byte-array:unref</h3>
  147. <div class="informalexample"><pre class="programlisting">(define-values () (byte-array:unref array))
  148. </pre></div>
  149. <p>Atomically decrements the reference count of <em class="parameter"><code>array</code></em> by one. If the
  150. reference count drops to 0, all memory allocated by the array is
  151. released. This function is thread-safe and may be called from any
  152. thread.</p>
  153. <div class="refsect3">
  154. <a name="id-1.1.5.3.7.4"></a><h4>Parameters</h4>
  155. <div class="informaltable"><table><tr>
  156. <td class="parameter_name"><p>array</p></td>
  157. <td class="parameter_description">
  158. <p>A <span class="type">GByteArray</span></p>
  159. <p>Passed as <code class="code">array</code></p>
  160. </td>
  161. </tr></table></div>
  162. </div>
  163. </div>
  164. </div>
  165. </div>
  166. <div class="footer">
  167. <hr>Generated by GTK-Doc V1.33.1</div>
  168. </body>
  169. </html>