eina_strbuf: add eina_strbuf_free_return
authorMarcel Hollerbach <marcel-hollerbach@t-online.de>
Tue, 3 Jan 2017 09:52:27 +0000 (10:52 +0100)
committerMarcel Hollerbach <marcel-hollerbach@t-online.de>
Thu, 5 Jan 2017 13:08:23 +0000 (14:08 +0100)
commit2f1d0fb18924b5c100dd2a5b149b4af505c87566
treeea9f0fff3e50f54d1670ff4e7db727109b8df7ca
parente998529f2e20ca70bf1ebc463473aedab153f84e
eina_strbuf: add eina_strbuf_free_return

Summary:
For a function which just composes a string with strbuf its quite
usefull to return the string while its freed.

This makes a function like:

{
   Eina_Strbuf *buf;
   char *path;

   buf = eina_strbuf_new();
   eina_strbuf_append(buf, "test");
   eina_strbuf_append_printf(buf, "%s-%d.edj", "test", 0);
   path = eina_strbuf_string_steal(buf);
   eina_strbuf_free(buf);
   return path;
}

To:

{
   Eina_Strbuf *buf;

   buf = eina_strbuf_new();
   eina_strbuf_append(buf, "test");
   eina_strbuf_append_printf(buf, "%s-%d.edj", "test", 0);
   return eina_strbuf_free_return(buf);
}

Which is a bit more handy.

Test Plan: just run make check

Reviewers: raster, cedric

Subscribers: jpeg

Differential Revision: https://phab.enlightenment.org/D4545
src/lib/eina/eina_strbuf.c
src/lib/eina/eina_strbuf.h
src/tests/eina/eina_test_strbuf.c