summaryrefslogtreecommitdiff
path: root/src/lib/eina
diff options
context:
space:
mode:
authorMarcel Hollerbach <marcel-hollerbach@t-online.de>2017-01-06 12:18:32 +0100
committerMarcel Hollerbach <marcel-hollerbach@t-online.de>2017-01-06 12:45:27 +0100
commit4d6d177ff71521d077e624dcadd4b4f84c14204a (patch)
tree442c323618abcadbbf6733fd738449aee3a446c5 /src/lib/eina
parentc7d23534d9b846bd23023a86d76a828bfa849333 (diff)
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.
Diffstat (limited to 'src/lib/eina')
-rw-r--r--src/lib/eina/eina_binbuf.h11
-rw-r--r--src/lib/eina/eina_binbuf_template_c.x11
-rw-r--r--src/lib/eina/eina_strbuf.c11
-rw-r--r--src/lib/eina/eina_strbuf.h2
-rw-r--r--src/lib/eina/eina_ustrbuf.h12
5 files changed, 35 insertions, 12 deletions
diff --git a/src/lib/eina/eina_binbuf.h b/src/lib/eina/eina_binbuf.h
index e10728e11a..8c6d3a46a4 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
388 * @since 1.19 388 * @since 1.19
389 */ 389 */
390EAPI Eina_Rw_Slice eina_binbuf_rw_slice_get(const Eina_Binbuf *buf) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); 390EAPI Eina_Rw_Slice eina_binbuf_rw_slice_get(const Eina_Binbuf *buf) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
391/**
392 * @brief Get the content of the buffer and free the buffer
393 *
394 * @param buf the buffer to get the content from and which will be freed
395 *
396 * @return The content contained by buf. The caller must release the memory of the returned content by calling
397 * free().
398 *
399 * @since 1.19
400 */
401EAPI unsigned char* eina_binbuf_release(Eina_Binbuf *buf) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
391 402
392/** 403/**
393 * @} 404 * @}
diff --git a/src/lib/eina/eina_binbuf_template_c.x b/src/lib/eina/eina_binbuf_template_c.x
index 72b6fd7972..2699997f9d 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)
216 EINA_MAGIC_CHECK_STRBUF(buf, ret); 216 EINA_MAGIC_CHECK_STRBUF(buf, ret);
217 return eina_strbuf_common_rw_slice_get(buf); 217 return eina_strbuf_common_rw_slice_get(buf);
218} 218}
219
220EAPI _STRBUF_DATA_TYPE*
221_FUNC_EXPAND(release)(_STRBUF_STRUCT_NAME *buf)
222{
223 _STRBUF_DATA_TYPE *result;
224
225 result = _FUNC_EXPAND(string_steal)(buf);
226 _FUNC_EXPAND(string_free)(buf);
227
228 return result;
229}
diff --git a/src/lib/eina/eina_strbuf.c b/src/lib/eina/eina_strbuf.c
index b784a701ab..81ab30a45f 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)
220 return eina_strbuf_manage_new(str); 220 return eina_strbuf_manage_new(str);
221} 221}
222 222
223EAPI char*
224eina_strbuf_free_return(Eina_Strbuf *buf)
225{
226 char *result;
227
228 result = eina_strbuf_string_steal(buf);
229 eina_strbuf_free(buf);
230
231 return result;
232}
233
234/* Unicode */ 223/* Unicode */
235 224
236#include "eina_strbuf_template_c.x" 225#include "eina_strbuf_template_c.x"
diff --git a/src/lib/eina/eina_strbuf.h b/src/lib/eina/eina_strbuf.h
index 9c2506c816..cd70a3dc8d 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
729 * 729 *
730 * @since 1.19 730 * @since 1.19
731 */ 731 */
732EAPI char* eina_strbuf_free_return(Eina_Strbuf *buf) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); 732EAPI char* eina_strbuf_release(Eina_Strbuf *buf) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
733 733
734/** 734/**
735 * @} 735 * @}
diff --git a/src/lib/eina/eina_ustrbuf.h b/src/lib/eina/eina_ustrbuf.h
index b0c6799772..f186b2cc7d 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
469EAPI Eina_Rw_Slice eina_ustrbuf_rw_slice_get(const Eina_UStrbuf *buf) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); 469EAPI Eina_Rw_Slice eina_ustrbuf_rw_slice_get(const Eina_UStrbuf *buf) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
470 470
471/** 471/**
472 * @brief Get the string of the buffer and free the buffer
473 *
474 * @param buf the buffer to get the string from and which will be freed
475 *
476 * @return The string contained by buf. The caller must release the memory of the returned string by calling
477 * free().
478 *
479 * @since 1.19
480 */
481EAPI Eina_Unicode* eina_ustrbuf_release(Eina_UStrbuf *buf) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
482
483/**
472 * @} 484 * @}
473 */ 485 */
474 486