Revision 43b793e3

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) {
src/Cache/topocache.h
32 32

  
33 33
void cache_log(const struct peer_cache *c, const char *name);
34 34

  
35
int cache_add_cache(struct peer_cache *dst, const struct peer_cache *src);
36

  
35 37
#endif  /* TOPOCACHE */
src/PeerSampler/cloudcast.c
92 92
  return 0;
93 93
}
94 94

  
95
static void cache_add_cache(struct peer_cache *dst, const struct peer_cache *add)
96
{
97
  int i, meta_size;
98
  const uint8_t *meta;
99

  
100
  meta = get_metadata(add, &meta_size);
101
  for (i = 0; nodeid(add, i); i++) {
102
    cache_add(dst,  nodeid(add, i), meta + (meta_size * i), meta_size);
103
  }
104
}
105

  
106 95
static int cache_add_resize(struct peer_cache *dst, struct nodeID *n, const int cache_max_size)
107 96
{
108 97
  int err;
src/PeerSampler/cyclon.c
74 74
  return 0;
75 75
}
76 76

  
77
static void cache_add_cache(struct peer_cache *dst, const struct peer_cache *add)
78
{
79
  int i, meta_size;
80
  const uint8_t *meta;
81

  
82
  meta = get_metadata(add, &meta_size);
83
  for (i = 0; nodeid(add, i); i++) {
84
    cache_add(dst,  nodeid(add, i), meta + (meta_size * i), meta_size);
85
  }
86
}
87

  
88

  
89 77
/*
90 78
 * Public Functions!
91 79
 */

Also available in: Unified diff