+/* We hash the call location together with its backtrace. */
+static size_t hash_call(const struct failtest_call *call)
+{
+ return hash(call->file, strlen(call->file),
+ hash(&call->line, 1,
+ hash(call->backtrace, call->backtrace_num,
+ call->type)));
+}
+
+static bool call_eq(const struct failtest_call *call1,
+ const struct failtest_call *call2)
+{
+ unsigned int i;
+
+ if (strcmp(call1->file, call2->file) != 0
+ || call1->line != call2->line
+ || call1->type != call2->type
+ || call1->backtrace_num != call2->backtrace_num)
+ return false;
+
+ for (i = 0; i < call1->backtrace_num; i++)
+ if (call1->backtrace[i] != call2->backtrace[i])
+ return false;
+
+ return true;
+}
+
+/* Defines struct failtable. */
+HTABLE_DEFINE_TYPE(struct failtest_call, (struct failtest_call *), hash_call,
+ call_eq, failtable);