* @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);
/**
* @}
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;
+}
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"
*
* @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);
/**
* @}
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);
+
+/**
* @}
*/
}
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
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);
}