13 static unsigned int fnv_hash(
void *key,
int len);
33 int *tuple = (
int*)malloc((len+1)*
sizeof(int));
34 prt_assert(tuple != NULL,
"malloc failed");
38 for (i = 0; i < len; i++)
39 tuple[i] = va_arg(ap,
int);
56 while (*p++ != INT_MAX);
75 va_start(ap, first_tuple);
77 while ((tuple = va_arg(ap,
int*)) != NULL)
81 int *out_tuple = (
int*)malloc((len+1)*
sizeof(int));
82 prt_assert(out_tuple != NULL,
"malloc failed");
83 va_start(ap, first_tuple);
84 while(*first_tuple != INT_MAX)
85 *out_tuple++ = *first_tuple++;
86 while ((tuple = va_arg(ap,
int*)) != NULL)
87 while(*tuple != INT_MAX)
88 *out_tuple++ = *tuple++;
92 return (out_tuple-len);
120 while (in_tuple[len] != INT_MAX)
122 out_tuple = (
int*)malloc((len+1)*
sizeof(int));
123 prt_assert(out_tuple != NULL,
"malloc failed");
124 for (i = 0; i < len; i++)
125 out_tuple[i] = in_tuple[i];
126 out_tuple[len] = INT_MAX;
143 int *tupa = (
int*)tuple_a;
144 int *tupb = (
int*)tuple_b;
145 while (*tupa != INT_MAX && *tupb != INT_MAX) {
146 if (*tupa < *tupb)
return -1;
147 else if (*tupa > *tupb)
return 1;
151 if (*tupa == INT_MAX && *tupb == INT_MAX)
return 0;
152 else if (*tupa == INT_MAX)
return -1;
153 else if (*tupb == INT_MAX)
return 1;
180 while (*tuple != INT_MAX)
181 printf(
"%3d", *tuple++);
197 int *tup = (
int*)tuple;
198 while (tup[len] != INT_MAX)
200 return fnv_hash(tuple, len*
sizeof(
int));
213 static unsigned int fnv_hash(
void *key,
int len)
215 unsigned char *p = key;
216 unsigned h = 2166136261;
218 for (i = 0; i < len; i++)
219 h = (h * 16777619) ^ p[i];