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