eina_stringshare_replace() gets in!
authorbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 8 Apr 2009 18:25:02 +0000 (18:25 +0000)
committerbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 8 Apr 2009 18:25:02 +0000 (18:25 +0000)
commit22589203bd87e975de65dbce5b94e15590bbefe5
treec92f03202144efa079b35ced2ba9aab3b1aa6960
parent1a94c7a22bf73692320ff1813fa8a3a44af61e80
eina_stringshare_replace() gets in!

I was replicating this code in many places, it should go into eina itself.

It's the right way to change strings that you don't know are
stringshared before, since it will first add a reference and then
remove, making it impossible to have references to go 0 and string
being released before adding new references, fixing the following
possible problem:

   x = eina_stringshare_add("x");
   replace(x, x);

   then:
   incorrect_replace(const char **b, const char *a) {
      eina_stringshare_del(*b); /* reference gets to 0 */
      eina_stringshare_add(a); /* BUG!!! */
      *b = a;
   }

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/eina@39903 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33
src/include/Makefile.am
src/include/eina_inline_stringshare.x [new file with mode: 0644]
src/include/eina_stringshare.h