Revision 8738ac23 src/Cache/topocache.c

View differences:

src/Cache/topocache.c
35 35
  if (c->current_size == c->cache_size) {
36 36
    return -2;
37 37
  }
38
  position = c->current_size;
38
  position = 0;
39 39
  for (i = 0; i < c->current_size; i++) {
40 40
if (e->id == NULL) {fprintf(stderr, "e->ID = NULL!!!\n"); *((char *)0) = 1;}
41 41
if (c->entries[i].id == NULL) {fprintf(stderr, "entries[%d]->ID = NULL!!!\n", i); exit(-1);}
42 42
    if (nodeid_equal(e->id, c->entries[i].id)) {
43 43
      return -1;
44 44
    }
45
    if (e->timestamp < c->entries[i].timestamp) {
46
       position = i;
47
     }
45
    if (c->entries[i].timestamp <= e->timestamp) {
46
      position = i + 1;
47
    }
48 48
  }
49 49

  
50 50
  memmove(c->entries + position + 1, c->entries + position, sizeof(struct cache_entry) * (c->current_size - position));

Also available in: Unified diff