Exemple #1
0
bool TestExtHash::test_hash_init() {
  Object ctx = f_hash_init("md5");
  f_hash_update(ctx, "The quick brown fox ");
  f_hash_update(ctx, "jumped over the lazy dog.");
  VS(f_hash_final(ctx), "5c6ffbdd40d9556b73a21e63c3e0e904");
  return Count(true);
}
Exemple #2
0
struct o_dictionary *f_dictionary_new(struct o_dictionary *supplied) {
	struct o_dictionary *result;
	if ((result = (struct o_dictionary *) f_object_new(v_dictionary_kind, sizeof(struct o_dictionary), (struct o_object *)supplied))) {
		p_dictionary_hooking(result);
		f_hash_init(&(result->table), p_dictionary_compare_hooker, p_dictionary_hash_hooker);
	}
	return result;
}
Exemple #3
0
struct o_object *p_dictionary_clone(struct o_object *object) {
	struct o_dictionary *result = NULL, *local_object;
	struct o_array *keys;
	struct o_object *key;
	size_t index;
	if ((local_object = d_object_kind(object, dictionary))) {
		result = (struct o_dictionary *)p_object_clone(object);
		result->table = NULL;
		f_hash_init(&(result->table), p_dictionary_compare_hooker, p_dictionary_hash_hooker);
		if ((keys = local_object->m_keys(local_object))) {
			for (index = 0; index < keys->size; index++) {
				key = keys->m_get(keys, index);
				result->m_insert(result, key, f_hash_get(local_object->table, key));
			}
			d_release(keys);
		}
	} else
		d_throw(v_exception_kind, "object is not an instance of o_dictionary");
	return (o_object *)result;
}
Exemple #4
0
struct s_object *f_map_new(struct s_object *self) {
  struct s_map_attributes *attributes = p_map_alloc(self);
  f_hash_init(&attributes->hash, (t_hash_compare *)f_object_compare, (t_hash_calculate *)f_object_hash);
  return self;
}