Revision 661d190d som/TopologyManager/topocache.c

View differences:

som/TopologyManager/topocache.c
289 289
  return res;
290 290
}
291 291

  
292
struct peer_cache *merge_caches_ranked(struct peer_cache *c1, struct peer_cache *c2, int newsize, ranking_function rank, struct peer_cache *me)
292
struct peer_cache *merge_caches_ranked(struct peer_cache *c1, struct peer_cache *c2, int newsize, int *source, ranking_function rank, struct peer_cache *me)
293 293
{
294 294
  int n1, n2;
295 295
  struct peer_cache *new_cache;
......
301 301
  }
302 302

  
303 303
  meta = new_cache->metadata;
304
  *source = 0;
304 305
  for (n1 = 0, n2 = 0; new_cache->current_size < new_cache->cache_size;) {
305 306
    if ((n1 == c1->current_size) && (n2 == c2->current_size)) {
306 307
      return new_cache;
......
313 314
        }
314 315
        new_cache->entries[new_cache->current_size++] = c2->entries[n2];
315 316
        c2->entries[n2].id = NULL;
317
        *source |= 0x02;
316 318
      }
317 319
      n2++;
318 320
    } else if (n2 == c2->current_size) {
......
323 325
        }
324 326
        new_cache->entries[new_cache->current_size++] = c1->entries[n1];
325 327
        c1->entries[n1].id = NULL;
328
        *source |= 0x01;
326 329
      }
327 330
      n1++;
328 331
    } else {
......
344 347
          }
345 348
          new_cache->entries[new_cache->current_size++] = c1->entries[n1];
346 349
          c1->entries[n1].id = NULL;
350
          *source |= 0x01;
347 351
        }
348 352
        n1++;
349 353
      } else {
......
354 358
          }
355 359
          new_cache->entries[new_cache->current_size++] = c2->entries[n2];
356 360
          c2->entries[n2].id = NULL;
361
          *source |= 0x02;
357 362
        }
358 363
        n2++;
359 364
      }
......
363 368
  return new_cache;
364 369
}
365 370

  
366
struct peer_cache *merge_caches(struct peer_cache *c1, struct peer_cache *c2, int newsize)
371
struct peer_cache *merge_caches(struct peer_cache *c1, struct peer_cache *c2, int newsize, int *source)
367 372
{
368
  return merge_caches_ranked(c1, c2, newsize, NULL, NULL);
373
  return merge_caches_ranked(c1, c2, newsize, source, NULL, NULL);
369 374
}

Also available in: Unified diff