Just use a standard C++ type for deduplicating instead of reinventing the wheel

This commit is contained in:
Eric Fischer
2014-10-31 16:50:28 -07:00
parent 8e84a8ffda
commit 3f9f50258c
3 changed files with 5 additions and 33 deletions
-26
View File
@@ -67,32 +67,6 @@ struct pool_val *pool(struct pool *p, char *s, int type) {
return pool1(p, s, type, strcmp);
}
static long long mangle(long long in) {
int i;
long long out = 0;
for (i = 0; i < 64; i++) {
out |= ((in >> i) & 1) << (63 - i);
}
return out;
}
static int llcmp(const char *v1, const char *v2) {
long long ll1 = mangle(*(long long *) v1);
long long ll2 = mangle(*(long long *) v2);
if (ll1 < ll2) {
return -1;
} else if (ll1 > ll2) {
return 1;
} else {
return 0;
}
}
struct pool_val *pool_long_long(struct pool *p, long long *s, int type) {
return pool1(p, (char *) s, type, llcmp);
}
void pool_free1(struct pool *p, void (*func)(void *)) {
while (p->head != NULL) {
if (func != NULL) {