From: Enlightenment S. <no-...@en...> - 2008-09-29 17:07:57
|
Log: Fix prev pointer during stringshare_del. Author: cedric Date: 2008-09-29 10:07:50 -0700 (Mon, 29 Sep 2008) New Revision: 36319 Modified: trunk/PROTO/eina/src/lib/eina_stringshare.c Modified: trunk/PROTO/eina/src/lib/eina_stringshare.c =================================================================== --- trunk/PROTO/eina/src/lib/eina_stringshare.c 2008-09-29 16:39:49 UTC (rev 36318) +++ trunk/PROTO/eina/src/lib/eina_stringshare.c 2008-09-29 17:07:50 UTC (rev 36319) @@ -112,6 +112,7 @@ { EINA_RBTREE; EINA_MAGIC; + int hash; Eina_Stringshare_Node *head; @@ -310,23 +311,24 @@ hash &= EINA_STRINGSHARE_MASK; ed = (Eina_Stringshare_Head*) eina_rbtree_inline_lookup((Eina_Rbtree*) share->buckets[hash_num], - &hash, sizeof (hash), + &hash, 0, EINA_RBTREE_CMP_KEY_CB(_eina_stringshare_cmp), NULL); if (!ed) { ed = malloc(sizeof (Eina_Stringshare_Head) + sizeof (Eina_Stringshare_Node) + slen); if (!ed) return NULL; + EINA_MAGIC_SET(ed, EINA_MAGIC_STRINGSHARE_HEAD); + ed->hash = hash; ed->head = NULL; - EINA_MAGIC_SET(ed, EINA_MAGIC_STRINGSHARE_HEAD); - share->buckets[hash_num] = (Eina_Stringshare_Head*) eina_rbtree_inline_insert((Eina_Rbtree*) share->buckets[hash_num], EINA_RBTREE_GET(ed), EINA_RBTREE_CMP_NODE_CB(_eina_stringshare_node), NULL); nel = (Eina_Stringshare_Node*) (ed + 1); EINA_MAGIC_SET(nel, EINA_MAGIC_STRINGSHARE_NODE); + nel->begin = EINA_TRUE; } @@ -354,9 +356,9 @@ { nel = malloc(sizeof (Eina_Stringshare_Node) + slen); if (!nel) return NULL; + EINA_MAGIC_SET(nel, EINA_MAGIC_STRINGSHARE_NODE); + nel->begin = EINA_FALSE; - - EINA_MAGIC_SET(nel, EINA_MAGIC_STRINGSHARE_NODE); } nel->references = 1; @@ -395,7 +397,7 @@ hash &= EINA_STRINGSHARE_MASK; ed = (Eina_Stringshare_Head*) eina_rbtree_inline_lookup(EINA_RBTREE_GET(share->buckets[hash_num]), - &hash, sizeof (hash), + &hash, 0, EINA_RBTREE_CMP_KEY_CB(_eina_stringshare_cmp), NULL); if (!ed) goto on_error; @@ -403,11 +405,13 @@ for (prev = NULL, el = ed->head; el && (const char*) (el + 1) != str; - el = el->next) + prev = el, el = el->next) ; if (!el) goto on_error; + EINA_MAGIC_CHECK_STRINGSHARE_NODE(el); + el->references--; if (el->references == 0) { |