bu5hm4n pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=4d6d177ff71521d077e624dcadd4b4f84c14204a

commit 4d6d177ff71521d077e624dcadd4b4f84c14204a
Author: Marcel Hollerbach <marcel-hollerb...@t-online.de>
Date:   Fri Jan 6 12:18:32 2017 +0100

    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.
---
 src/lib/eina/eina_binbuf.h            | 11 +++++++++++
 src/lib/eina/eina_binbuf_template_c.x | 11 +++++++++++
 src/lib/eina/eina_strbuf.c            | 11 -----------
 src/lib/eina/eina_strbuf.h            |  2 +-
 src/lib/eina/eina_ustrbuf.h           | 12 ++++++++++++
 src/tests/eina/eina_test_strbuf.c     | 10 +++++-----
 6 files changed, 40 insertions(+), 17 deletions(-)

diff --git a/src/lib/eina/eina_binbuf.h b/src/lib/eina/eina_binbuf.h
index e10728e..8c6d3a4 100644
--- a/src/lib/eina/eina_binbuf.h
+++ b/src/lib/eina/eina_binbuf.h
@@ -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);
 
 /**
  * @}
diff --git a/src/lib/eina/eina_binbuf_template_c.x 
b/src/lib/eina/eina_binbuf_template_c.x
index 72b6fd7..2699997 100644
--- a/src/lib/eina/eina_binbuf_template_c.x
+++ b/src/lib/eina/eina_binbuf_template_c.x
@@ -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;
+}
diff --git a/src/lib/eina/eina_strbuf.c b/src/lib/eina/eina_strbuf.c
index b784a70..81ab30a 100644
--- a/src/lib/eina/eina_strbuf.c
+++ b/src/lib/eina/eina_strbuf.c
@@ -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"
diff --git a/src/lib/eina/eina_strbuf.h b/src/lib/eina/eina_strbuf.h
index 9c2506c..cd70a3d 100644
--- a/src/lib/eina/eina_strbuf.h
+++ b/src/lib/eina/eina_strbuf.h
@@ -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);
 
 /**
  * @}
diff --git a/src/lib/eina/eina_ustrbuf.h b/src/lib/eina/eina_ustrbuf.h
index b0c6799..f186b2c 100644
--- a/src/lib/eina/eina_ustrbuf.h
+++ b/src/lib/eina/eina_ustrbuf.h
@@ -469,6 +469,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);
+
+/**
  * @}
  */
 
diff --git a/src/tests/eina/eina_test_strbuf.c 
b/src/tests/eina/eina_test_strbuf.c
index 8206720..0511d96 100644
--- a/src/tests/eina/eina_test_strbuf.c
+++ b/src/tests/eina/eina_test_strbuf.c
@@ -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);
 }

-- 


Reply via email to