static int compute_minsum(int *matrix, int n) { #define ASSIGN_DIST()\ new_dist = dist[i] + matrix[j];\ if (new_dist < dist[j])\ dist[j] = new_dist unsigned int dist[n*n]; memset(dist, 255, n*n * sizeof(int)); dist[0] = matrix[0]; for (int i = 0; i < n*n; ++i) { int j, new_dist; // move right if ((j = i + 1) < n*n && j % n > 0) { ASSIGN_DIST(); } // move down if ((j = i + n) < n*n) { ASSIGN_DIST(); } } return dist[n*n - 1]; #undef ASSIGN_DIST }
/* Fetch package data from HostNode and feed it into the hashtables. */ void autoref_add_host_info(HostNode *node) { Distri distri; if(!test_hostnode(node)) return; if (!ht_distris) ht_distris = g_hash_table_new(distri_hash, distri_equal); #ifdef NDEBUG #define ASSIGN_DIST(d, n, f) \ (d).lsb_distributor = f((n)->lsb_distributor); \ (d).lsb_release = f((n)->lsb_release); \ (d).lsb_codename = f((n)->lsb_codename); \ (d).uname_kernel = f((n)->uname_kernel); \ (d).uname_machine = f((n)->uname_machine); #else #define ASSIGN_DIST(d, n, f) \ (d)._type = T_DISTRI; \ (d).lsb_distributor = f((n)->lsb_distributor); \ (d).lsb_release = f((n)->lsb_release); \ (d).lsb_codename = f((n)->lsb_codename); \ (d).uname_kernel = f((n)->uname_kernel); \ (d).uname_machine = f((n)->uname_machine); #endif ASSIGN_DIST(distri, node, ); /* Create distri hashtable if needed. */ GHashTable *ht_packages = g_hash_table_lookup(ht_distris, &distri); if(!ht_packages) { ht_packages = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); Distri *ndistri = g_malloc(sizeof(Distri)); #ifndef NDEBUG ndistri->_type = T_DISTRI; #endif ASSIGN_DIST(*ndistri, node, g_strdup); g_hash_table_insert(ht_distris, ndistri, ht_packages); } /* Traverse package list and count installed versions. */ gpointer data[2]; data[0] = ht_packages; data[1] = node; g_list_foreach(node->packages, add_pkg, data); }