Revision 0c6efcd5

View differences:

include/peer.h
12 12
#include <sys/time.h>
13 13

  
14 14
struct peer {
15
    struct nodeID *id; ///< NodeId associated to the peer
16
    struct timeval creation_timestamp; ///< creation timestamp
17
    struct chunkID_set *bmap; ///< buffermap of the peer
18
    struct timeval bmap_timestamp; ///< buffermap timestamp
19
    void * metadata;
15
    /* Peer identifier, the nodeid associated with the peer */
16
    struct nodeID *id;
17

  
18
    /* Peer creation time */
19
    struct timeval creation_timestamp; 
20

  
21
    /* User defined data to be broadcasted in the network */
22
    void * metadata; 
23

  
24
    /* User defined data not to be sent over the network */
25
    void * user_data;
20 26
};
21 27

  
22 28

  
src/PeerSet/peerset_ops.c
153 153
  memmove(&h->elements[pos + 1], &h->elements[pos] , ((h->n_elements++) - pos) * sizeof(struct peer *));
154 154

  
155 155
  e = malloc(sizeof(struct peer));
156
  h->elements[pos] = e;;
156
  h->elements[pos] = e;
157
  gettimeofday(&e->creation_timestamp, NULL);
157 158
  e->id = nodeid_dup(id);
158
  gettimeofday(&e->creation_timestamp,NULL);
159
  e->bmap = chunkID_set_init("type=bitmap");
160
  timerclear(&e->bmap_timestamp);
161 159
  e->metadata = NULL;
160
  e->user_data = NULL;
162 161

  
163 162
  return h->n_elements;
164 163
}
......
204 203
  if (i >= 0) {
205 204
    struct peer *e = h->elements[i];
206 205
    nodeid_free(e->id);
207
    chunkID_set_free(e->bmap);
206
    if (e->metadata)
207
	    free(e->metadata);
208
    if (e->user_data)
209
	    free(e->user_data);
208 210
    memmove(&h->elements[i], &h->elements[i+1], ((h->n_elements--) - (i+1)) * sizeof(struct peer *));
209 211
    free(e);
210 212

  
......
229 231
  for (i = 0; i < h->n_elements; i++) {
230 232
    struct peer *e = h->elements[i];
231 233
    nodeid_free(e->id);
232
    chunkID_set_free(e->bmap);
233 234
    if (e->metadata)
234 235
	    free(e->metadata);
236
    if (e->user_data)
237
	    free(e->user_data);
235 238
    free(e);
236 239
  }
237 240

  
src/Tests/peer.c
23 23
	res = (struct peer *)malloc(*size);
24 24
	res->id = nodeid_dup(id);
25 25
	gettimeofday(&(res->creation_timestamp),NULL);
26
	gettimeofday(&(res->bmap_timestamp),NULL);
27
	res->bmap = chunkID_set_init(0);
28 26
	return res;
29 27
}
30 28

  
31 29
void peerDelete (struct peer *p) {
32 30
	nodeid_free(p->id);
33
	chunkID_set_free(p->bmap);
34 31
	free(p);
35 32
}
36 33

  
......
56 53
	*size = *size + sizeof(int);
57 54

  
58 55
	gettimeofday(&(p->creation_timestamp),NULL);
59
	gettimeofday(&(p->bmap_timestamp),NULL);
60
	p->bmap = chunkID_set_init(0);
61 56

  
62 57
	return p;
63 58

  

Also available in: Unified diff