Remove dead code, sprintf_alloc() cannot fail. Opkg will exit instead.
[oweals/opkg-lede.git] / libopkg / hash_table.h
index d4e8a3d78d38450bb85d7be6541c481c8f1ab706..472b3e244e7224f873f2c3de9b5d35cee67ea97f 100644 (file)
@@ -1,7 +1,7 @@
 /* hash.h - hash tables for opkg
 
    Steven M. Ayer, Jamey Hicks
-   
+
    Copyright (C) 2002 Compaq Computer Corporation
 
    This program is free software; you can redistribute it and/or
@@ -28,17 +28,24 @@ struct hash_entry {
 };
 
 struct hash_table {
-  const char *name; 
-  hash_entry_t * entries;  
-  int n_entries; /* number of buckets */
-  int n_elements;
-  const char * (*hash_entry_key)(void * data);
+  const char *name;
+  hash_entry_t * entries;
+  unsigned int n_buckets;
+  unsigned int n_elements;
+
+  /* useful stats */
+  unsigned int n_used_buckets;
+  unsigned int n_collisions;
+  unsigned int max_bucket_len;
+  unsigned int n_hits, n_misses;
 };
 
-int hash_table_init(const char *name, hash_table_t *hash, int len);
+void hash_table_init(const char *name, hash_table_t *hash, int len);
 void hash_table_deinit(hash_table_t *hash);
+void hash_print_stats(hash_table_t *hash);
 void *hash_table_get(hash_table_t *hash, const char *key);
 int hash_table_insert(hash_table_t *hash, const char *key, void *value);
+int hash_table_remove(hash_table_t *has, const char *key);
 void hash_table_foreach(hash_table_t *hash, void (*f)(const char *key, void *entry, void *data), void *data);
 
 #endif /* _HASH_TABLE_H_ */