int snd_output_stdio_attach(snd_output_t **outputp, FILE *fp, int _close);
int snd_output_buffer_open(snd_output_t **outputp);
size_t snd_output_buffer_string(snd_output_t *output, char **buf);
+size_t snd_output_buffer_steal(snd_output_t *output, char **buf);
int snd_output_close(snd_output_t *output);
int snd_output_printf(snd_output_t *output, const char *format, ...)
#ifndef DOC_HIDDEN
size_t alloc;
unsigned char *buf;
+ /* use 'size++' to allow to add the '\0' string terminator */
+ /* without reallocation */
+ size++;
if (_free >= size)
return _free;
if (buffer->alloc == 0)
return buffer->size;
}
+/**
+ * \brief Returns the address of the buffer of a #SND_OUTPUT_BUFFER output handle.
+ * \param output The output handle.
+ * \param buf The functions puts the current address of the buffer at the
+ * address specified by \p buf.
+ * \return The current size of valid data in the buffer.
+ *
+ * The internal buffer is empty after this call. The caller has the responsibility
+ * to clean the buffer using the free() call.
+ */
+size_t snd_output_buffer_steal(snd_output_t *output, char **buf)
+{
+ snd_output_buffer_t *buffer = output->private_data;
+ size_t size;
+ *buf = (char *)buffer->buf;
+ size = buffer->size;
+ buffer->buf = NULL;
+ buffer->alloc = 0;
+ buffer->size = 0;
+ return size;
+}
+
/**
* \brief Creates a new output object with an auto-extending memory buffer.
* \param outputp The function puts the pointer to the new output object
*outputp = output;
return 0;
}
-