From dd0ba39af3cbf06b2abb4165d8c696778d3c560e Mon Sep 17 00:00:00 2001 From: Philipp Schafft Date: Sat, 14 Sep 2019 20:00:58 +0000 Subject: [PATCH] Update: Converted igloo_ro_new_ext() to include a instance parameter --- include/igloo/buffer.h | 2 +- include/igloo/ro.h | 2 +- src/buffer.c | 4 ++-- src/tests/ctest_buffer.c | 6 +++--- src/tests/ctest_refobject.c | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/igloo/buffer.h b/include/igloo/buffer.h index f9749e2..77f2dd0 100644 --- a/include/igloo/buffer.h +++ b/include/igloo/buffer.h @@ -45,7 +45,7 @@ igloo_RO_FORWARD_TYPE(igloo_buffer_t); * userdata, name, associated * See refobject_new(). */ -igloo_buffer_t * igloo_buffer_new(ssize_t preallocation, const char *name, igloo_ro_t associated); +igloo_buffer_t * igloo_buffer_new(ssize_t preallocation, const char *name, igloo_ro_t associated, igloo_ro_t instance); /* Depreciated: This creates a new buffer with defaults. * Do NOT use this. Use refobject_new(igloo_buffer_t) diff --git a/include/igloo/ro.h b/include/igloo/ro.h index b0bac7f..1e03b3b 100644 --- a/include/igloo/ro.h +++ b/include/igloo/ro.h @@ -292,7 +292,7 @@ igloo_ro_t igloo_ro_new__raw(const igloo_ro_type_t *type, const char *name, igloo_ro_t igloo_ro_new__simple(const igloo_ro_type_t *type, const char *name, igloo_ro_t associated, igloo_ro_t instance, ...); #define igloo_ro_new(type, ...) igloo_RO_TO_TYPE(igloo_ro_new__simple(igloo_RO_GET_TYPE_BY_SYMBOL(type), NULL, igloo_RO_NULL, igloo_RO_NULL, ## __VA_ARGS__), type) -#define igloo_ro_new_ext(type, name, associated, ...) igloo_RO_TO_TYPE(igloo_ro_new__simple(igloo_RO_GET_TYPE_BY_SYMBOL(type), (name), (associated), igloo_RO_NULL, ## __VA_ARGS__), type) +#define igloo_ro_new_ext(type, name, associated, instance, ...) igloo_RO_TO_TYPE(igloo_ro_new__simple(igloo_RO_GET_TYPE_BY_SYMBOL(type), (name), (associated), (instance), ## __VA_ARGS__), type) /* This increases the reference counter of the object */ igloo_error_t igloo_ro_ref(igloo_ro_t self); diff --git a/src/buffer.c b/src/buffer.c index 2d71302..20d296f 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -46,9 +46,9 @@ static void __free(igloo_ro_t self) free(buffer->buffer); } -igloo_buffer_t * igloo_buffer_new(ssize_t preallocation, const char *name, igloo_ro_t associated) +igloo_buffer_t * igloo_buffer_new(ssize_t preallocation, const char *name, igloo_ro_t associated, igloo_ro_t instance) { - igloo_buffer_t *buffer = igloo_ro_new_ext(igloo_buffer_t, name, associated); + igloo_buffer_t *buffer = igloo_ro_new_ext(igloo_buffer_t, name, associated, instance); if (!buffer) return NULL; diff --git a/src/tests/ctest_buffer.c b/src/tests/ctest_buffer.c index 2b1d96b..4ff429f 100644 --- a/src/tests/ctest_buffer.c +++ b/src/tests/ctest_buffer.c @@ -22,7 +22,7 @@ static void test_create_ref_unref(void) { igloo_buffer_t *a; - a = igloo_buffer_new(-1, NULL, igloo_RO_NULL); + a = igloo_buffer_new(-1, NULL, igloo_RO_NULL, igloo_RO_NULL); ctest_test("buffer created", a != NULL); ctest_test("un-referenced", igloo_ro_unref(a) == igloo_ERROR_NONE); @@ -38,7 +38,7 @@ static void test_name(void) const char *name = "test object name"; const char *ret; - a = igloo_buffer_new(-1, name, igloo_RO_NULL); + a = igloo_buffer_new(-1, name, igloo_RO_NULL, igloo_RO_NULL); ctest_test("buffer created", a != NULL); ret = igloo_ro_get_name(a); @@ -57,7 +57,7 @@ static void test_associated(void) ctest_test("refobject created", !igloo_RO_IS_NULL(a)); - b = igloo_buffer_new(-1, NULL, a); + b = igloo_buffer_new(-1, NULL, a, igloo_RO_NULL); ctest_test("buffer created with associated", !igloo_RO_IS_NULL(b)); ctest_test("un-referenced (1 of 2)", igloo_ro_unref(b) == igloo_ERROR_NONE); diff --git a/src/tests/ctest_refobject.c b/src/tests/ctest_refobject.c index a5ce008..724515f 100644 --- a/src/tests/ctest_refobject.c +++ b/src/tests/ctest_refobject.c @@ -180,7 +180,7 @@ static void test_name(void) const char *name = "test object name"; const char *ret; - a = igloo_ro_new_ext(igloo_ro_base_t, name, igloo_RO_NULL); + a = igloo_ro_new_ext(igloo_ro_base_t, name, igloo_RO_NULL, igloo_RO_NULL); ctest_test("refobject created", !igloo_RO_IS_NULL(a)); ret = igloo_ro_get_name(a); @@ -197,7 +197,7 @@ static void test_associated(void) a = igloo_ro_new(igloo_ro_base_t); ctest_test("refobject created", !igloo_RO_IS_NULL(a)); - b = igloo_ro_new_ext(igloo_ro_base_t, NULL, a); + b = igloo_ro_new_ext(igloo_ro_base_t, NULL, a, igloo_RO_NULL); ctest_test("refobject created with associated", !igloo_RO_IS_NULL(b)); ctest_test("un-referenced (1 of 2)", igloo_ro_unref(b) == igloo_ERROR_NONE);