Revision 505990dd

View differences:

src/Cache/topocache.c
50 50
        nodeid_free(c->entries[i].id);
51 51
        c->entries[i] = *e;
52 52
        memcpy(c->metadata + i * c->metadata_size, meta, c->metadata_size);
53
        memmove(c->entries + position + 1, c->entries + position, sizeof(struct cache_entry) * (i - position));
54
        memmove(c->metadata + (position + 1) * c->metadata_size, c->metadata + position * c->metadata_size, (i -position) * c->metadata_size);
53
        if (position != i) {
54
          memmove(c->entries + position + 1, c->entries + position, sizeof(struct cache_entry) * (i - position));
55
          memmove(c->metadata + (position + 1) * c->metadata_size, c->metadata + position * c->metadata_size, (i -position) * c->metadata_size);
56
        }
55 57

  
56 58
        return position;
57 59
      }

Also available in: Unified diff