From: barbieri Date: Thu, 16 Feb 2012 19:31:56 +0000 (+0000) Subject: 2/3 eina_model: properly eliminate duplicates. X-Git-Tag: 2.0_alpha~33^2~25 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=36b76ea98622ed17d4b1cfdfc7b7b542f4f3e8b8;p=framework%2Fuifw%2Feina.git 2/3 eina_model: properly eliminate duplicates. We must check for duplicates otherwise we'll have remaining entries after topological sort. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/eina@68033 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/lib/eina_model.c b/src/lib/eina_model.c index 104f4dd..70d5fad 100644 --- a/src/lib/eina_model.c +++ b/src/lib/eina_model.c @@ -524,7 +524,7 @@ _eina_model_description_ifaces_fix(Eina_Model_Description *desc) unsigned int users; Eina_List *deps; } *nodes, **pending, **roots; - unsigned int n_nodes = desc->total.ifaces, n_pending = 0, n_roots = 0, i; + unsigned int n_nodes = desc->total.ifaces, n_pending = 0, n_roots = 0, i, j; Eina_Bool ret = EINA_TRUE; nodes = alloca(n_nodes * sizeof(struct node)); @@ -532,15 +532,26 @@ _eina_model_description_ifaces_fix(Eina_Model_Description *desc) roots = alloca(n_nodes * sizeof(struct node *)); /* populate */ - for (i = 0; i < n_nodes; i++) + for (i = 0, j = 0; i < n_nodes; i++) { - nodes[i].iface = desc->cache.ifaces[i]; - nodes[i].users = 0; - nodes[i].deps = NULL; + unsigned int k; + for (k = 0; k < j; k++) + { + if (nodes[k].iface == desc->cache.ifaces[i]) + break; + } + if (k < j) + continue; /* already exists */ + + nodes[j].iface = desc->cache.ifaces[i]; + nodes[j].users = 0; + nodes[j].deps = NULL; + j++; } + n_nodes = j; + for (i = 0; i < n_nodes; i++) { - unsigned int j; for (j = 0; j < n_nodes; j++) { if (i == j) continue; @@ -580,8 +591,6 @@ _eina_model_description_ifaces_fix(Eina_Model_Description *desc) EINA_LIST_FREE(r->deps, d) { - unsigned int j; - d->users--; if (d->users > 0) continue;