diff --git a/src/libsail-common/iccp.c b/src/libsail-common/iccp.c index ad248cdf..2e397e95 100644 --- a/src/libsail-common/iccp.c +++ b/src/libsail-common/iccp.c @@ -62,7 +62,7 @@ sail_status_t sail_alloc_iccp_from_data(const void *data, unsigned data_length, return SAIL_OK; } -sail_status_t sail_alloc_iccp_move_data(void *data, unsigned data_length, struct sail_iccp **iccp) { +sail_status_t sail_alloc_iccp_from_shallow_data(void *data, unsigned data_length, struct sail_iccp **iccp) { SAIL_CHECK_PTR(data); SAIL_CHECK_PTR(iccp); diff --git a/src/libsail-common/iccp.h b/src/libsail-common/iccp.h index 91dbf720..519ead29 100644 --- a/src/libsail-common/iccp.h +++ b/src/libsail-common/iccp.h @@ -67,12 +67,12 @@ SAIL_EXPORT sail_status_t sail_alloc_iccp(struct sail_iccp **iccp); SAIL_EXPORT sail_status_t sail_alloc_iccp_from_data(const void *data, unsigned data_length, struct sail_iccp **iccp); /* - * Allocates a new ICC profile and copies the external pointer to a ICC profile data into it. - * DO NOT free the external pointer as it will be freed in sail_destroy_iccp(), beware of double free. + * Allocates a new ICC profile and copies the external pointer to another ICC data into it. + * Do not free the external pointer. It will be freed in sail_destroy_iccp(). * * Returns SAIL_OK on success. */ -SAIL_EXPORT sail_status_t sail_alloc_iccp_move_data(void *data, unsigned data_length, struct sail_iccp **iccp); +SAIL_EXPORT sail_status_t sail_alloc_iccp_from_shallow_data(void *data, unsigned data_length, struct sail_iccp **iccp); /* * Destroys the specified ICC profile and all its internal allocated memory buffers. diff --git a/src/libsail-common/variant.c b/src/libsail-common/variant.c index 5065d347..5efd32cb 100644 --- a/src/libsail-common/variant.c +++ b/src/libsail-common/variant.c @@ -171,7 +171,7 @@ sail_status_t sail_set_variant_string(struct sail_variant *variant, const char * return SAIL_OK; } -sail_status_t sail_set_variant_adopted_string(struct sail_variant *variant, char *value) { +sail_status_t sail_set_variant_shallow_string(struct sail_variant *variant, char *value) { SAIL_CHECK_PTR(variant); @@ -201,7 +201,7 @@ sail_status_t sail_set_variant_data(struct sail_variant *variant, const void *va return SAIL_OK; } -sail_status_t sail_set_variant_adopted_data(struct sail_variant *variant, void *value, size_t size) { +sail_status_t sail_set_variant_shallow_data(struct sail_variant *variant, void *value, size_t size) { SAIL_CHECK_PTR(variant); diff --git a/src/libsail-common/variant.h b/src/libsail-common/variant.h index d1c06ef3..7e185bd2 100644 --- a/src/libsail-common/variant.h +++ b/src/libsail-common/variant.h @@ -184,10 +184,11 @@ SAIL_EXPORT sail_status_t sail_set_variant_string(struct sail_variant *variant, /* * Sets a shallow copy of the specified string as a new variant value. * Transfers the ownership of the string to the constructed variant. + * Do not free the string pointer. It will be freed in sail_destroy_variant(). * * Returns SAIL_OK on success. */ -SAIL_EXPORT sail_status_t sail_set_variant_adopted_string(struct sail_variant *variant, char *value); +SAIL_EXPORT sail_status_t sail_set_variant_shallow_string(struct sail_variant *variant, char *value); /* * Sets a deep copy of the specified substring as a new variant value. @@ -209,10 +210,11 @@ SAIL_EXPORT sail_status_t sail_set_variant_data(struct sail_variant *variant, co /* * Sets a shallow copy of the specified data buffer as a new variant value. * Transfers the ownership of the data pointer to the variant. + * Do not free the data pointer. It will be freed in sail_destroy_variant(). * * Returns SAIL_OK on success. */ -SAIL_EXPORT sail_status_t sail_set_variant_adopted_data(struct sail_variant *variant, void *value, size_t size); +SAIL_EXPORT sail_status_t sail_set_variant_shallow_data(struct sail_variant *variant, void *value, size_t size); /* * Returns the variant value as a boolean. Behavior is undefined if the variant is invalid. diff --git a/src/sail-codecs/common/bmp/helpers.c b/src/sail-codecs/common/bmp/helpers.c index e70f412a..ffccfead 100644 --- a/src/sail-codecs/common/bmp/helpers.c +++ b/src/sail-codecs/common/bmp/helpers.c @@ -140,7 +140,7 @@ sail_status_t bmp_private_fetch_iccp(struct sail_io *io, long offset_of_data, ui SAIL_TRY_OR_CLEANUP(io->strict_read(io->stream, profile_data, profile_size), /* cleanup */ sail_free(profile_data)); - SAIL_TRY_OR_CLEANUP(sail_alloc_iccp_move_data(profile_data, profile_size, iccp), + SAIL_TRY_OR_CLEANUP(sail_alloc_iccp_from_shallow_data(profile_data, profile_size, iccp), /* cleanup */ sail_free(profile_data)); return SAIL_OK; diff --git a/tests/sail-common/iccp.c b/tests/sail-common/iccp.c index ae1a18a2..0f000747 100644 --- a/tests/sail-common/iccp.c +++ b/tests/sail-common/iccp.c @@ -105,7 +105,7 @@ static MunitResult test_iccp_from_shallow_data(const MunitParameter params[], vo munit_assert_not_null(data); struct sail_iccp *iccp = NULL; - munit_assert(sail_alloc_iccp_move_data(data, data_length, &iccp) == SAIL_OK); + munit_assert(sail_alloc_iccp_from_shallow_data(data, data_length, &iccp) == SAIL_OK); munit_assert_not_null(iccp); munit_assert(iccp->data_length == data_length); diff --git a/tests/sail-common/variant.c b/tests/sail-common/variant.c index 6721bb19..96d38722 100644 --- a/tests/sail-common/variant.c +++ b/tests/sail-common/variant.c @@ -144,7 +144,7 @@ static MunitResult test_from_string(const MunitParameter params[], void *user_da strcpy(str, "xyz"); #endif - TEST_VARIANT_FROM_STRING(str, sail_set_variant_adopted_string, SAIL_VARIANT_TYPE_STRING, sail_variant_to_string); + TEST_VARIANT_FROM_STRING(str, sail_set_variant_shallow_string, SAIL_VARIANT_TYPE_STRING, sail_variant_to_string); return MUNIT_OK; } @@ -183,7 +183,7 @@ static MunitResult test_from_data(const MunitParameter params[], void *user_data strcpy(str, "xyz"); #endif - TEST_VARIANT_FROM_DATA(str, 3, sail_set_variant_adopted_data, SAIL_VARIANT_TYPE_DATA, sail_variant_to_data); + TEST_VARIANT_FROM_DATA(str, 3, sail_set_variant_shallow_data, SAIL_VARIANT_TYPE_DATA, sail_variant_to_data); return MUNIT_OK; }