Revision 43b793e3 src/Cache/topocache.c

View differences:

src/Cache/topocache.c
73 73
  return position;
74 74
}
75 75

  
76
int cache_add_cache(struct peer_cache *dst, const struct peer_cache *src)
77
{
78
  struct cache_entry *e_orig;
79
  int count, j;
80
  struct cache_entry e_dup;
81
cache_check(dst);
82
cache_check(src);
83

  
84
  count = 0;
85
  j=0;
86
  while(dst->current_size < dst->cache_size && src->current_size > count) {
87
    count++;
88

  
89
    e_orig = src->entries + j;
90

  
91
    e_dup.id = nodeid_dup(e_orig->id);
92
    e_dup.timestamp = e_orig->timestamp;
93

  
94
    if (cache_insert(dst, &e_dup, src->metadata + src->metadata_size * j) < 0) {
95
      nodeid_free(e_dup.id);
96
    }
97
    j++;
98
  }
99
cache_check(dst);
100
cache_check(src);
101

  
102
  return dst->current_size;
103
}
104

  
76 105
struct nodeID *nodeid(const struct peer_cache *c, int i)
77 106
{
78 107
  if (i < c->current_size) {

Also available in: Unified diff