equal
deleted
inserted
replaced
3 /** @file queue.cpp */ |
3 /** @file queue.cpp */ |
4 |
4 |
5 #include "stdafx.h" |
5 #include "stdafx.h" |
6 #include "openttd.h" |
6 #include "openttd.h" |
7 #include "queue.h" |
7 #include "queue.h" |
8 #include "helpers.hpp" |
8 #include "core/alloc_func.hpp" |
9 |
9 |
10 |
10 |
11 /* |
11 /* |
12 * Insertion Sorter |
12 * Insertion Sorter |
13 */ |
13 */ |
308 debug("Allocated hash: %p", h); |
308 debug("Allocated hash: %p", h); |
309 #endif |
309 #endif |
310 h->hash = hash; |
310 h->hash = hash; |
311 h->size = 0; |
311 h->size = 0; |
312 h->num_buckets = num_buckets; |
312 h->num_buckets = num_buckets; |
313 h->buckets = (HashNode*)malloc(num_buckets * (sizeof(*h->buckets) + sizeof(*h->buckets_in_use))); |
313 h->buckets = (HashNode*)MallocT<byte>(num_buckets * (sizeof(*h->buckets) + sizeof(*h->buckets_in_use))); |
314 #ifdef HASH_DEBUG |
314 #ifdef HASH_DEBUG |
315 debug("Buckets = %p", h->buckets); |
315 debug("Buckets = %p", h->buckets); |
316 #endif |
316 #endif |
317 h->buckets_in_use = (bool*)(h->buckets + num_buckets); |
317 h->buckets_in_use = (bool*)(h->buckets + num_buckets); |
318 for (i = 0; i < num_buckets; i++) h->buckets_in_use[i] = false; |
318 for (i = 0; i < num_buckets; i++) h->buckets_in_use[i] = false; |