} TableData;
static size_t TABLE_CELL_TO_INDEX(TableCell *cell) {
- unsigned i;
+ size_t i;
assert(cell);
- i = PTR_TO_UINT(cell);
+ i = PTR_TO_SIZE(cell);
assert(i > 0);
return i-1;
static TableCell* TABLE_INDEX_TO_CELL(size_t index) {
assert(index != (size_t) -1);
- return UINT_TO_PTR((unsigned) (index + 1));
+ return SIZE_TO_PTR(index + 1);
}
struct Table {
return 0;
case TABLE_TIMESTAMP:
- if (a->timestamp < b->timestamp)
- return -1;
- if (a->timestamp > b->timestamp)
- return 1;
- return 0;
+ return CMP(a->timestamp, b->timestamp);
case TABLE_TIMESPAN:
- if (a->timespan < b->timespan)
- return -1;
- if (a->timespan > b->timespan)
- return 1;
- return 0;
+ return CMP(a->timespan, b->timespan);
case TABLE_SIZE:
- if (a->size < b->size)
- return -1;
- if (a->size > b->size)
- return 1;
- return 0;
+ return CMP(a->size, b->size);
case TABLE_UINT32:
- if (a->uint32 < b->uint32)
- return -1;
- if (a->uint32 > b->uint32)
- return 1;
- return 0;
+ return CMP(a->uint32, b->uint32);
default:
;
}
/* Generic fallback using the orginal order in which the cells where added. */
- if (index_a < index_b)
- return -1;
- if (index_a > index_b)
- return 1;
-
- return 0;
+ return CMP(index_a, index_b);
}
static int table_data_compare(const size_t *a, const size_t *b, Table *t) {