eina_stringshare_replace() gets in!
authorGustavo Sverzut Barbieri <barbieri@gmail.com>
Wed, 8 Apr 2009 18:25:02 +0000 (18:25 +0000)
committerGustavo Sverzut Barbieri <barbieri@gmail.com>
Wed, 8 Apr 2009 18:25:02 +0000 (18:25 +0000)
commit619ed37fed98fe47ae0936dafd62f69dc7fa0958
treef57dc394378591a9019c7df90a8b42985f121e49
parent3836c7ba2ba065ff5b5553400f0bad738434f714
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;
   }

SVN revision: 39903
src/bin/e_fm.c
src/bin/e_fm_op_registry.c