Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static uint64_t dp(device *d, device *t, cache **kache) {
- if (d == t) {
- return 1;
- } else {
- cache *ca = NULL;
- HASH_FIND(hh, *kache, &d, sizeof(device *), ca);
- if (ca != NULL) {
- return ca->n;
- }
- ca = (cache *)malloc(sizeof(cache));
- ca->n = 0;
- ca->d = d;
- for (int i = 0; i < d->n; i++) {
- device *d0 = d->os[i];
- ca->n += dp(d0, t, kache);
- }
- HASH_ADD(hh, *kache, d, sizeof(device *), ca);
- return ca->n;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment