X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fvalue.c;h=9fcf1cbb9b8fa0a97cb4e75544a9a6892879ab68;hb=b734a970ee8bfda57e72398d4f424fb16f2ea80a;hp=49555d9a4ea3b11ce15149ebdca388722af6dcb4;hpb=a2f24e20cafce5616db69902a1594911ab026978;p=pspp diff --git a/src/data/value.c b/src/data/value.c index 49555d9a4e..9fcf1cbb9b 100644 --- a/src/data/value.c +++ b/src/data/value.c @@ -20,6 +20,7 @@ #include #include #include +#include "variable.h" #include "xalloc.h" @@ -46,8 +47,12 @@ value_create (int width) Only the short string portion of longer strings are compared. */ int -compare_values (const union value *a, const union value *b, int width) +compare_values (const void *a_, const void *b_, const void *var_) { + const union value *a = a_; + const union value *b = b_; + const struct variable *var = var_; + int width = var_get_width (var); return (width == 0 ? (a->f < b->f ? -1 : a->f > b->f) : memcmp (a->s, b->s, MIN (MAX_SHORT_STRING, width))); @@ -56,24 +61,14 @@ compare_values (const union value *a, const union value *b, int width) /* Create a hash of V, which has the given WIDTH. Only the short string portion of a longer string is hashed. */ unsigned -hash_value (const union value *v, int width) +hash_value (const void *v_, const void *var_) { + const union value *v = v_; + const struct variable *var = var_; + int width = var_get_width (var); return (width == 0 ? hsh_hash_double (v->f) - : hsh_hash_bytes (v->s, MIN (MAX_SHORT_STRING, width))); -} - - -int -compare_ptr_values (const union value **v1, const union value **v2, int width) -{ - return compare_values (*v1, *v2, width); -} - -unsigned -hash_ptr_value (const union value **v, int width) -{ - return hash_value (*v, width); + : hsh_hash_bytes (v->s, width)); }