forked from enlightenment/efl
eina_buf: replace eina_strbuf_free_return with eina_xXxbuf_release
The api name free_return wasnt a good choice so it is changed to release. This also moves the implementation to binbuf template so it is available in all buf types.
This commit is contained in:
parent
c7d23534d9
commit
4d6d177ff7
|
@ -388,6 +388,17 @@ EAPI Eina_Slice eina_binbuf_slice_get(const Eina_Binbuf *buf) EINA_WARN_UNUSED_R
|
|||
* @since 1.19
|
||||
*/
|
||||
EAPI Eina_Rw_Slice eina_binbuf_rw_slice_get(const Eina_Binbuf *buf) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
|
||||
/**
|
||||
* @brief Get the content of the buffer and free the buffer
|
||||
*
|
||||
* @param buf the buffer to get the content from and which will be freed
|
||||
*
|
||||
* @return The content contained by buf. The caller must release the memory of the returned content by calling
|
||||
* free().
|
||||
*
|
||||
* @since 1.19
|
||||
*/
|
||||
EAPI unsigned char* eina_binbuf_release(Eina_Binbuf *buf) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
|
|
@ -216,3 +216,14 @@ _FUNC_EXPAND(rw_slice_get)(const _STRBUF_STRUCT_NAME *buf)
|
|||
EINA_MAGIC_CHECK_STRBUF(buf, ret);
|
||||
return eina_strbuf_common_rw_slice_get(buf);
|
||||
}
|
||||
|
||||
EAPI _STRBUF_DATA_TYPE*
|
||||
_FUNC_EXPAND(release)(_STRBUF_STRUCT_NAME *buf)
|
||||
{
|
||||
_STRBUF_DATA_TYPE *result;
|
||||
|
||||
result = _FUNC_EXPAND(string_steal)(buf);
|
||||
_FUNC_EXPAND(string_free)(buf);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -220,17 +220,6 @@ eina_strbuf_substr_get(Eina_Strbuf *buf, size_t pos, size_t len)
|
|||
return eina_strbuf_manage_new(str);
|
||||
}
|
||||
|
||||
EAPI char*
|
||||
eina_strbuf_free_return(Eina_Strbuf *buf)
|
||||
{
|
||||
char *result;
|
||||
|
||||
result = eina_strbuf_string_steal(buf);
|
||||
eina_strbuf_free(buf);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Unicode */
|
||||
|
||||
#include "eina_strbuf_template_c.x"
|
||||
|
|
|
@ -729,7 +729,7 @@ EAPI Eina_Rw_Slice eina_strbuf_rw_slice_get(const Eina_Strbuf *buf) EINA_WARN_UN
|
|||
*
|
||||
* @since 1.19
|
||||
*/
|
||||
EAPI char* eina_strbuf_free_return(Eina_Strbuf *buf) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
|
||||
EAPI char* eina_strbuf_release(Eina_Strbuf *buf) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
|
|
@ -468,6 +468,18 @@ EAPI Eina_Slice eina_ustrbuf_slice_get(const Eina_UStrbuf *buf) EINA_WARN_UNUSED
|
|||
*/
|
||||
EAPI Eina_Rw_Slice eina_ustrbuf_rw_slice_get(const Eina_UStrbuf *buf) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
|
||||
|
||||
/**
|
||||
* @brief Get the string of the buffer and free the buffer
|
||||
*
|
||||
* @param buf the buffer to get the string from and which will be freed
|
||||
*
|
||||
* @return The string contained by buf. The caller must release the memory of the returned string by calling
|
||||
* free().
|
||||
*
|
||||
* @since 1.19
|
||||
*/
|
||||
EAPI Eina_Unicode* eina_ustrbuf_release(Eina_UStrbuf *buf) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
@ -646,17 +646,17 @@ START_TEST(strbuf_prepend_print)
|
|||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(strbuf_free_return_test)
|
||||
START_TEST(strbuf_release_test)
|
||||
{
|
||||
Eina_Strbuf *buf;
|
||||
char *string;
|
||||
|
||||
buf = eina_strbuf_new();
|
||||
ck_assert_ptr_ne(buf, NULL);
|
||||
eina_strbuf_append(buf, "strbuf_free_return_test");
|
||||
eina_strbuf_append(buf, "strbuf_release_test");
|
||||
|
||||
string = eina_strbuf_free_return(buf);
|
||||
ck_assert_str_eq(string, "strbuf_free_return_test");
|
||||
string = eina_strbuf_release(buf);
|
||||
ck_assert_str_eq(string, "strbuf_release_test");
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
@ -676,5 +676,5 @@ eina_test_strbuf(TCase *tc)
|
|||
tcase_add_test(tc, strbuf_tolower);
|
||||
tcase_add_test(tc, strbuf_substr_get);
|
||||
tcase_add_test(tc, strbuf_prepend_print);
|
||||
tcase_add_test(tc, strbuf_free_return_test);
|
||||
tcase_add_test(tc, strbuf_release_test);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue