ucx/buffer.h

changeset 168
24a012440dee
parent 166
350a0e3898bd
child 169
279dd3ca7a77
equal deleted inserted replaced
167:aed60ba37acf 168:24a012440dee
118 * 118 *
119 * <b>Note:</b> the #UCX_BUFFER_AUTOFREE feature is enforced for the new buffer. 119 * <b>Note:</b> the #UCX_BUFFER_AUTOFREE feature is enforced for the new buffer.
120 * 120 *
121 * @param src the source buffer 121 * @param src the source buffer
122 * @param start the start position of extraction 122 * @param start the start position of extraction
123 * @param length the count of bytes to extract or 0 if all of the remaining 123 * @param length the count of bytes to extract (must not be zero)
124 * bytes shall be extracted
125 * @param flags feature mask for the new buffer 124 * @param flags feature mask for the new buffer
126 * @return a new buffer containing the extraction 125 * @return a new buffer containing the extraction
127 */ 126 */
128 UcxBuffer* ucx_buffer_extract(UcxBuffer *src, 127 UcxBuffer* ucx_buffer_extract(UcxBuffer *src,
129 size_t start, size_t length, int flags); 128 size_t start, size_t length, int flags);
134 * @param src the source buffer 133 * @param src the source buffer
135 * @param flags feature mask for the new buffer 134 * @param flags feature mask for the new buffer
136 * @return a new buffer with the extracted content 135 * @return a new buffer with the extracted content
137 */ 136 */
138 #define ucx_buffer_clone(src,flags) \ 137 #define ucx_buffer_clone(src,flags) \
139 ucx_buffer_extract(src, 0, 0, flags) 138 ucx_buffer_extract(src, 0, (src)->capacity, flags)
140 139
141 /** 140 /**
142 * Moves the position of the buffer. 141 * Moves the position of the buffer.
143 * 142 *
144 * The new position is relative to the <code>whence</code> argument. 143 * The new position is relative to the <code>whence</code> argument.
184 * 183 *
185 * <b>Note:</b> The buffer capacity increased by a power of two. I.e. 184 * <b>Note:</b> The buffer capacity increased by a power of two. I.e.
186 * the buffer capacity is doubled, as long as it would not hold the current 185 * the buffer capacity is doubled, as long as it would not hold the current
187 * content plus the additional required bytes. 186 * content plus the additional required bytes.
188 * 187 *
189 * <b>Attention:</b> the argument provided is the count of <i>additional</i> 188 * <b>Attention:</b> the argument provided is the number of <i>additional</i>
190 * bytes the buffer shall hold. It is <b>NOT</b> the total count of bytes the 189 * bytes the buffer shall hold. It is <b>NOT</b> the total number of bytes the
191 * buffer shall hold. 190 * buffer shall hold.
192 * 191 *
193 * @param buffer the buffer to extend 192 * @param buffer the buffer to extend
194 * @param additional_bytes the count of additional bytes the buffer shall 193 * @param additional_bytes the number of additional bytes the buffer shall
195 * <i>at least</i> hold 194 * <i>at least</i> hold
196 * @return 0 on success or a non-zero value on failure 195 * @return 0 on success or a non-zero value on failure
197 */ 196 */
198 int ucx_buffer_extend(UcxBuffer *buffer, size_t additional_bytes); 197 int ucx_buffer_extend(UcxBuffer *buffer, size_t additional_bytes);
199 198

mercurial