/* Copyright (C) 2002, 2004 Christopher Clark <firstname.lastname@cl.cam.ac.uk>
- *
+ *
* Modified 2009 by Barret Rhoden <brho@cs.berkeley.edu>
* Changes include:
* - No longer frees keys or values. It's up to the client to do that.
* externing the hentry cache.
* - hash for each */
-#ifndef __ROS_KERN_HASHTABLE_H__
-#define __ROS_KERN_HASHTABLE_H__
+#pragma once
#include <ros/common.h>
* v = (struct some_value *) kmalloc(sizeof(struct some_value));
*
* (initialise k and v to suitable values)
- *
+ *
* if (! hashtable_insert(h,k,v) )
* { panic("Hashtable broken...\n"); }
*
/* Macros may be used to define type-safe(r) hashtable access functions, with
* methods specialized to take known key and value types as parameters.
- *
+ *
* Example:
*
* Insert this at the start of your file:
/*****************************************************************************
* create_hashtable
-
+
* @name create_hashtable
* @param minsize minimum initial size of hashtable
* @param hashfunction function for hashing keys
/*****************************************************************************
* hashtable_insert
-
+
* @name hashtable_insert
* @param h the hashtable to insert into
* @param k the key
* If in doubt, remove before insert.
*/
-ssize_t
+ssize_t
hashtable_insert(hashtable_t *h, void *k, void *v);
#define DEFINE_HASHTABLE_INSERT(fnname, keytype, valuetype) \
/*****************************************************************************
* hashtable_search
-
+
* @name hashtable_search
* @param h the hashtable to search
* @param k the key to search for
/*****************************************************************************
* hashtable_remove
-
+
* @name hashtable_remove
* @param h the hashtable to remove the item from
* @param k the key to search for
/*****************************************************************************
* hashtable_count
-
+
* @name hashtable_count
* @param h the hashtable
* @return the number of items stored in the hashtable
/*****************************************************************************
* hashtable_destroy
-
+
* @name hashtable_destroy
* @param h the hashtable
*
}
/* Runs func on each member of the hash table */
-void hash_for_each(struct hashtable *hash, void func(void*));
+void hash_for_each(struct hashtable *hash, void func(void *, void *),
+ void *opaque);
/* Same, but removes the item too */
-void hash_for_each_remove(struct hashtable *hash, void func(void*));
-
-#endif /* __ROS_KERN_HASHTABLE_H__ */
+void hash_for_each_remove(struct hashtable *hash, void func(void *, void *),
+ void *opaque);
/*
* Copyright (c) 2002, 2004, Christopher Clark
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
- *
+ *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR