Skip to content

Commit

Permalink
COMMON: Rename moved and adopted to shallow
Browse files Browse the repository at this point in the history
  • Loading branch information
HappySeaFox committed Oct 11, 2023
1 parent ec213f5 commit 07468e6
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/libsail-common/iccp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/libsail-common/iccp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/libsail-common/variant.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down
6 changes: 4 additions & 2 deletions src/libsail-common/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/sail-codecs/common/bmp/helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/sail-common/iccp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions tests/sail-common/variant.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 07468e6

Please sign in to comment.