Commit bdbe3379 authored by Philipp Schafft's avatar Philipp Schafft 🦁

Update: Replaced buffer_new_simple() by refobject_new(buffer_t)

parent 48bb4773
...@@ -38,12 +38,13 @@ static void __free(refobject_t self, void **userdata) ...@@ -38,12 +38,13 @@ static void __free(refobject_t self, void **userdata)
} }
REFOBJECT_DEFINE_TYPE(buffer_t, REFOBJECT_DEFINE_TYPE(buffer_t,
REFOBJECT_DEFINE_TYPE_FREE(__free) REFOBJECT_DEFINE_TYPE_FREE(__free),
REFOBJECT_DEFINE_TYPE_NEW_NOOP()
); );
buffer_t * buffer_new(ssize_t preallocation, void *userdata, const char *name, refobject_t associated) buffer_t * buffer_new(ssize_t preallocation, void *userdata, const char *name, refobject_t associated)
{ {
buffer_t *buffer = refobject_new__new(buffer_t, userdata, name, associated); buffer_t *buffer = refobject_new_ext(buffer_t, userdata, name, associated);
if (!buffer) if (!buffer)
return NULL; return NULL;
...@@ -56,7 +57,7 @@ buffer_t * buffer_new(ssize_t preallocation, void *userdata, const char *name, ...@@ -56,7 +57,7 @@ buffer_t * buffer_new(ssize_t preallocation, void *userdata, const char *name,
buffer_t * buffer_new_simple(void) buffer_t * buffer_new_simple(void)
{ {
return buffer_new(-1, NULL, NULL, REFOBJECT_NULL); return refobject_new(buffer_t);
} }
void buffer_preallocate(buffer_t *buffer, size_t request) void buffer_preallocate(buffer_t *buffer, size_t request)
......
...@@ -39,7 +39,9 @@ REFOBJECT_FORWARD_TYPE(buffer_t); ...@@ -39,7 +39,9 @@ REFOBJECT_FORWARD_TYPE(buffer_t);
*/ */
buffer_t * buffer_new(ssize_t preallocation, void *userdata, const char *name, refobject_t associated); buffer_t * buffer_new(ssize_t preallocation, void *userdata, const char *name, refobject_t associated);
/* This creates a new buffer with defaults. /* Depreciated: This creates a new buffer with defaults.
* Do NOT use this. Use refobject_new(buffer_t)
*
* This is the same as: * This is the same as:
* buffer_new(-1, NULL, NULL, REFOBJECT_NULL) * buffer_new(-1, NULL, NULL, REFOBJECT_NULL)
*/ */
......
...@@ -25,7 +25,7 @@ static void test_create_ref_unref(void) ...@@ -25,7 +25,7 @@ static void test_create_ref_unref(void)
ctest_test("buffer created", a != NULL); ctest_test("buffer created", a != NULL);
ctest_test("un-referenced", refobject_unref(a) == 0); ctest_test("un-referenced", refobject_unref(a) == 0);
a = buffer_new_simple(); a = refobject_new(buffer_t);
ctest_test("buffer created", a != NULL); ctest_test("buffer created", a != NULL);
ctest_test("un-referenced", refobject_unref(a) == 0); ctest_test("un-referenced", refobject_unref(a) == 0);
...@@ -102,7 +102,7 @@ static void test_empty(void) ...@@ -102,7 +102,7 @@ static void test_empty(void)
const char *string; const char *string;
int ret; int ret;
a = buffer_new_simple(); a = refobject_new(buffer_t);
ctest_test("buffer created", a != NULL); ctest_test("buffer created", a != NULL);
ret = buffer_get_data(a, &data, &length); ret = buffer_get_data(a, &data, &length);
...@@ -147,7 +147,7 @@ static void test_string(void) ...@@ -147,7 +147,7 @@ static void test_string(void)
const char *string = NULL; const char *string = NULL;
int ret; int ret;
a = buffer_new_simple(); a = refobject_new(buffer_t);
ctest_test("buffer created", a != NULL); ctest_test("buffer created", a != NULL);
ctest_test("pushed string", buffer_push_string(a, hw) == 0); ctest_test("pushed string", buffer_push_string(a, hw) == 0);
ret = buffer_get_string(a, &string); ret = buffer_get_string(a, &string);
...@@ -182,7 +182,7 @@ static void test_binary(void) ...@@ -182,7 +182,7 @@ static void test_binary(void)
size_t length; size_t length;
const void *data; const void *data;
a = buffer_new_simple(); a = refobject_new(buffer_t);
ctest_test("buffer created", a != NULL); ctest_test("buffer created", a != NULL);
ctest_test("pushed data pattern a", buffer_push_data(a, pattern_a, sizeof(pattern_a)) == 0); ctest_test("pushed data pattern a", buffer_push_data(a, pattern_a, sizeof(pattern_a)) == 0);
...@@ -238,7 +238,7 @@ static void test_shift(void) ...@@ -238,7 +238,7 @@ static void test_shift(void)
buffer_t *a; buffer_t *a;
const char *pattern = "AABBBCC"; const char *pattern = "AABBBCC";
a = buffer_new_simple(); a = refobject_new(buffer_t);
ctest_test("buffer created", a != NULL); ctest_test("buffer created", a != NULL);
ctest_test("pushed string", buffer_push_string(a, pattern) == 0); ctest_test("pushed string", buffer_push_string(a, pattern) == 0);
...@@ -264,7 +264,7 @@ static void test_length(void) ...@@ -264,7 +264,7 @@ static void test_length(void)
const char *match_b = "AABB"; const char *match_b = "AABB";
const char *match_c = ""; const char *match_c = "";
a = buffer_new_simple(); a = refobject_new(buffer_t);
ctest_test("buffer created", a != NULL); ctest_test("buffer created", a != NULL);
ctest_test("pushed string", buffer_push_string(a, pattern) == 0); ctest_test("pushed string", buffer_push_string(a, pattern) == 0);
...@@ -290,7 +290,7 @@ static void test_printf(void) ...@@ -290,7 +290,7 @@ static void test_printf(void)
const char *match_b = ":Hello World!:<-127 >"; const char *match_b = ":Hello World!:<-127 >";
const char *match_c = ":Hello World!:<-127 >? +127?"; const char *match_c = ":Hello World!:<-127 >? +127?";
a = buffer_new_simple(); a = refobject_new(buffer_t);
ctest_test("buffer created", a != NULL); ctest_test("buffer created", a != NULL);
ctest_test("Set length to match pattern a", buffer_push_printf(a, ":%s:", str) == 0); ctest_test("Set length to match pattern a", buffer_push_printf(a, ":%s:", str) == 0);
...@@ -310,9 +310,9 @@ static void test_push_buffer(void) ...@@ -310,9 +310,9 @@ static void test_push_buffer(void)
const char *pattern = "AABBBCC"; const char *pattern = "AABBBCC";
const char *match_a = "AABBBCCAABBBCC"; const char *match_a = "AABBBCCAABBBCC";
a = buffer_new_simple(); a = refobject_new(buffer_t);
ctest_test("buffer a created", a != NULL); ctest_test("buffer a created", a != NULL);
b = buffer_new_simple(); b = refobject_new(buffer_t);
ctest_test("buffer b created", b != NULL); ctest_test("buffer b created", b != NULL);
ctest_test("pushed string", buffer_push_string(a, pattern) == 0); ctest_test("pushed string", buffer_push_string(a, pattern) == 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment