-/*
- * Copyright (C) 2008 Stig Venaas <venaas@uninett.no>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- */
+/* Copyright (c) 2006-2010, UNINETT AS.
+ * Copyright (c) 2010-2012, NORDUnet A/S. */
+/* See LICENSE for licensing information. */
#include <stdlib.h>
#include <string.h>
/* frees all memory associated with the hash */
void hash_destroy(struct hash *h) {
struct list_node *ln;
-
+
if (!h)
return;
for (ln = list_first(h->hashlist); ln; ln = list_next(ln)) {
void *hash_read(struct hash *h, void *key, uint32_t keylen) {
struct list_node *ln;
struct hash_entry *e;
-
+
if (!h)
return 0;
pthread_mutex_lock(&h->mutex);
for (ln = list_first(h->hashlist); ln; ln = list_next(ln)) {
e = (struct hash_entry *)ln->data;
if (e->keylen == keylen && !memcmp(e->key, key, keylen)) {
- pthread_mutex_unlock(&h->mutex);
- return e->data;
+ pthread_mutex_unlock(&h->mutex);
+ return e->data;
}
}
pthread_mutex_unlock(&h->mutex);
void *hash_extract(struct hash *h, void *key, uint32_t keylen) {
struct list_node *ln;
struct hash_entry *e;
-
+
if (!h)
return 0;
pthread_mutex_lock(&h->mutex);
e->next = (struct list_node *)entry->next->next;
return e;
}
+
+/* Local Variables: */
+/* c-file-style: "stroustrup" */
+/* End: */