mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-05 18:05:42 +02:00
Sort the index
This commit is contained in:
@@ -126,6 +126,19 @@ struct index {
|
|||||||
struct index *next;
|
struct index *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int indexcmp(const void *v1, const void *v2) {
|
||||||
|
const struct index *i1 = v1;
|
||||||
|
const struct index *i2 = v2;
|
||||||
|
|
||||||
|
if (i1->index < i2->index) {
|
||||||
|
return -1;
|
||||||
|
} else if (i1->index > i2->index) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void serialize_int(FILE *out, int n, long long *fpos) {
|
void serialize_int(FILE *out, int n, long long *fpos) {
|
||||||
fwrite(&n, sizeof(int), 1, out);
|
fwrite(&n, sizeof(int), 1, out);
|
||||||
*fpos += sizeof(int);
|
*fpos += sizeof(int);
|
||||||
@@ -221,6 +234,8 @@ void check(struct index *ix, long long n) {
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
|
printf("%llx ", ix[i].index);
|
||||||
|
|
||||||
off_t pos = ix[i].fpos;
|
off_t pos = ix[i].fpos;
|
||||||
fseeko(f, pos, SEEK_SET);
|
fseeko(f, pos, SEEK_SET);
|
||||||
|
|
||||||
@@ -393,6 +408,7 @@ next_feature:
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qsort(index, st.st_size / sizeof(struct index), sizeof(struct index), indexcmp);
|
||||||
check(index, st.st_size / sizeof(struct index));
|
check(index, st.st_size / sizeof(struct index));
|
||||||
|
|
||||||
munmap(index, st.st_size);
|
munmap(index, st.st_size);
|
||||||
|
|||||||
Reference in New Issue
Block a user