summaryrefslogtreecommitdiff
path: root/src/pathfinder/npf/queue.cpp
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2010-10-02 19:43:29 +0000
committeralberth <alberth@openttd.org>2010-10-02 19:43:29 +0000
commitd86f781ca54faf13bab50b2817cbce82546b0760 (patch)
tree180cb8f441c515571eb99949bf565c303c18dbf6 /src/pathfinder/npf/queue.cpp
parentf185a352693d3d78ced707ef990ccb44a84203e9 (diff)
downloadopenttd-d86f781ca54faf13bab50b2817cbce82546b0760.tar.xz
(svn r20884) -Codechange: Make clear_Hash a method.
Diffstat (limited to 'src/pathfinder/npf/queue.cpp')
-rw-r--r--src/pathfinder/npf/queue.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/pathfinder/npf/queue.cpp b/src/pathfinder/npf/queue.cpp
index eac77145b..0c8573e36 100644
--- a/src/pathfinder/npf/queue.cpp
+++ b/src/pathfinder/npf/queue.cpp
@@ -346,23 +346,26 @@ static void stat_Hash(const Hash *h)
}
#endif
-void clear_Hash(Hash *h, bool free_values)
+/**
+ * Cleans the hash, but keeps the memory allocated
+ */
+void Hash::Clear(bool free_values)
{
uint i;
#ifdef HASH_STATS
- if (h->size > 2000) stat_Hash(h);
+ if (this->size > 2000) stat_Hash(this);
#endif
/* Iterate all buckets */
- for (i = 0; i < h->num_buckets; i++) {
- if (h->buckets_in_use[i]) {
+ for (i = 0; i < this->num_buckets; i++) {
+ if (this->buckets_in_use[i]) {
HashNode *node;
- h->buckets_in_use[i] = false;
+ this->buckets_in_use[i] = false;
/* Free the first value */
- if (free_values) free(h->buckets[i].value);
- node = h->buckets[i].next;
+ if (free_values) free(this->buckets[i].value);
+ node = this->buckets[i].next;
while (node != NULL) {
HashNode *prev = node;
@@ -372,7 +375,7 @@ void clear_Hash(Hash *h, bool free_values)
}
}
}
- h->size = 0;
+ this->size = 0;
}
/**