p11_index_new (p11_index_build_cb build,
               p11_index_store_cb store,
               p11_index_remove_cb remove,
               p11_index_notify_cb notify,
               void *data)
{
	p11_index *index;

	index = calloc (1, sizeof (p11_index));
	return_val_if_fail (index != NULL, NULL);

	if (build == NULL)
		build = default_build;
	if (store == NULL)
		store = default_store;
	if (notify == NULL)
		notify = default_notify;
	if (remove == NULL)
		remove = default_remove;

	index->build = build;
	index->store = store;
	index->notify = notify;
	index->remove = remove;
	index->data = data;

	index->objects = p11_dict_new (p11_dict_ulongptr_hash,
	                               p11_dict_ulongptr_equal,
	                               NULL, free_object);
	if (index->objects == NULL) {
		p11_index_free (index);
		return_val_if_reached (NULL);
	}

	index->buckets = calloc (NUM_BUCKETS, sizeof (index_bucket));
	if (index->buckets == NULL) {
		p11_index_free (index);
		return_val_if_reached (NULL);
	}

	return index;
}
p11_index_new (p11_index_build_cb build,
               p11_index_store_cb store,
               p11_index_remove_cb remove,
               p11_index_notify_cb notify,
               void *data)
{
	p11_index *index;

	index = calloc (1, sizeof (p11_index));
	return_val_if_fail (index != NULL, NULL);

	if (build == NULL)
		build = default_build;
	if (store == NULL)
		store = default_store;
	if (notify == NULL)
		notify = default_notify;
	if (remove == NULL)
		remove = default_remove;

	index->build = build;
	index->store = store;
	index->notify = notify;
	index->remove = remove;
	index->data = data;

	index->objects = p11_dict_new (p11_dict_ulongptr_hash,
	                               p11_dict_ulongptr_equal,
	                               NULL, free_object);
	if (index->objects == NULL) {
		p11_index_free (index);
		return_val_if_reached (NULL);
	}

	index->buckets = calloc (NUM_BUCKETS, sizeof (index_bucket));
	if (index->buckets == NULL) {
		p11_index_free (index);
		return_val_if_reached (NULL);
	}

	return index;
}