* struct buffer_list
*/
struct buffer_list *
-buffer_list_new(const int max_size)
+buffer_list_new(void)
{
struct buffer_list *ret;
ALLOC_OBJ_CLEAR(ret, struct buffer_list);
- ret->max_size = max_size;
ret->size = 0;
return ret;
}
buffer_list_push_data(struct buffer_list *ol, const void *data, size_t size)
{
struct buffer_entry *e = NULL;
- if (data && (!ol->max_size || ol->size < ol->max_size))
+ if (data)
{
ALLOC_OBJ_CLEAR(e, struct buffer_entry);
char *line = (char *) malloc(max_line_len);
if (line)
{
- bl = buffer_list_new(0);
+ bl = buffer_list_new();
while (fgets(line, max_line_len, fp) != NULL)
{
buffer_list_push(bl, line);
}
if (mode == IER_NEW)
{
- mc->in_extra = buffer_list_new(0);
+ mc->in_extra = buffer_list_new();
}
}
}
* command output from/to the socket.
*/
man->connection.in = command_line_new(1024);
- man->connection.out = buffer_list_new(0);
+ man->connection.out = buffer_list_new();
/*
* Initialize event set for standalone usage, when we are
test_buffer_list_setup(void **state)
{
struct test_buffer_list_aggregate_ctx *ctx = calloc(1, sizeof(*ctx));
- ctx->empty = buffer_list_new(0);
+ ctx->empty = buffer_list_new();
- ctx->one_two_three = buffer_list_new(3);
+ ctx->one_two_three = buffer_list_new();
buffer_list_push(ctx->one_two_three, teststr1);
buffer_list_push(ctx->one_two_three, teststr2);
buffer_list_push(ctx->one_two_three, teststr3);
- ctx->zero_length_strings = buffer_list_new(2);
+ ctx->zero_length_strings = buffer_list_new();
buffer_list_push(ctx->zero_length_strings, "");
buffer_list_push(ctx->zero_length_strings, "");
- ctx->empty_buffers = buffer_list_new(2);
+ ctx->empty_buffers = buffer_list_new();
uint8_t data = 0;
buffer_list_push_data(ctx->empty_buffers, &data, 0);
buffer_list_push_data(ctx->empty_buffers, &data, 0);
return 0;
}
-static void
-test_buffer_list_full(void **state)
-{
- struct test_buffer_list_aggregate_ctx *ctx = *state;
-
- /* list full */
- assert_int_equal(ctx->one_two_three->size, 3);
- buffer_list_push(ctx->one_two_three, teststr4);
- assert_int_equal(ctx->one_two_three->size, 3);
-}
-
static void
test_buffer_list_aggregate_separator_empty(void **state)
{
{
const struct CMUnitTest tests[] = {
cmocka_unit_test(test_buffer_strprefix),
- cmocka_unit_test_setup_teardown(test_buffer_list_full,
- test_buffer_list_setup,
- test_buffer_list_teardown),
cmocka_unit_test_setup_teardown(test_buffer_list_aggregate_separator_empty,
test_buffer_list_setup,
test_buffer_list_teardown),