You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
579 B
33 lines
579 B
#include "str.h"
|
|
#include <assert.h>
|
|
|
|
guint str_hash(gconstpointer ss) {
|
|
const str *s = ss;
|
|
guint ret = 0;
|
|
str it = *s;
|
|
|
|
while (it.len >= sizeof(guint)) {
|
|
guint *x = (void *) it.s;
|
|
ret ^= *x;
|
|
it.s += sizeof(guint);
|
|
it.len -= sizeof(guint);
|
|
}
|
|
while (it.len >= sizeof(gushort)) {
|
|
gushort *x = (void *) it.s;
|
|
ret ^= *x;
|
|
it.s += sizeof(gushort);
|
|
it.len -= sizeof(gushort);
|
|
}
|
|
while (it.len > 0) {
|
|
ret ^= *it.s;
|
|
it.s++;
|
|
it.len--;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
gboolean str_equal(gconstpointer a, gconstpointer b) {
|
|
return str_cmp_str((str *) a, (str *) b) == 0;
|
|
}
|