mirror of
https://gitlab.xiph.org/xiph/icecast-common.git
synced 2024-12-04 14:46:31 -05:00
Feature: Added igloo_ro_stringify() support to buffers
This commit is contained in:
parent
d1e2abbddd
commit
b92d680fcc
@ -81,6 +81,8 @@ void igloo_buffer_preallocate(igloo_buffer_t *buffer, size_t request);
|
|||||||
int igloo_buffer_get_data(igloo_buffer_t *buffer, const void **data, size_t *length);
|
int igloo_buffer_get_data(igloo_buffer_t *buffer, const void **data, size_t *length);
|
||||||
|
|
||||||
/* Gets data as a string. The string is '\0'-terminated.
|
/* Gets data as a string. The string is '\0'-terminated.
|
||||||
|
* igloo_ro_stringify(buffer) will also return this buffer.
|
||||||
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* buffery
|
* buffery
|
||||||
* The buffer to operate on.
|
* The buffer to operate on.
|
||||||
|
18
src/buffer.c
18
src/buffer.c
@ -31,10 +31,12 @@ struct igloo_buffer_tag {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void __free(igloo_ro_t self);
|
static void __free(igloo_ro_t self);
|
||||||
|
static char * __stringify(igloo_ro_t self);
|
||||||
|
|
||||||
igloo_RO_PUBLIC_TYPE(igloo_buffer_t,
|
igloo_RO_PUBLIC_TYPE(igloo_buffer_t,
|
||||||
igloo_RO_TYPEDECL_FREE(__free),
|
igloo_RO_TYPEDECL_FREE(__free),
|
||||||
igloo_RO_TYPEDECL_NEW_NOOP()
|
igloo_RO_TYPEDECL_NEW_NOOP(),
|
||||||
|
igloo_RO_TYPEDECL_STRINGIFY(__stringify)
|
||||||
);
|
);
|
||||||
|
|
||||||
static void __free(igloo_ro_t self)
|
static void __free(igloo_ro_t self)
|
||||||
@ -139,6 +141,20 @@ int igloo_buffer_get_string(igloo_buffer_t *buffer, const char **string)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char * __stringify(igloo_ro_t self)
|
||||||
|
{
|
||||||
|
igloo_buffer_t *buffer = igloo_RO_TO_TYPE(self, igloo_buffer_t);
|
||||||
|
const char *ret;
|
||||||
|
|
||||||
|
if (!buffer)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (igloo_buffer_get_string(buffer, &ret) != 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return strdup(ret);
|
||||||
|
}
|
||||||
|
|
||||||
int igloo_buffer_set_length(igloo_buffer_t *buffer, size_t length)
|
int igloo_buffer_set_length(igloo_buffer_t *buffer, size_t length)
|
||||||
{
|
{
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
|
Loading…
Reference in New Issue
Block a user