Compare commits
No commits in common. "2021092a17b810d08d655f48cadca945d26258f5" and "af50174b71853f3ca887fc0e064e88258c412f2c" have entirely different histories.
2021092a17
...
af50174b71
16
debug.h
16
debug.h
|
@ -11,20 +11,6 @@
|
|||
extern int g_debug_error_abort;
|
||||
extern int g_debug_log_lvl;
|
||||
|
||||
#ifdef NDEBUG
|
||||
|
||||
#define LOG_INFO(...)
|
||||
#define LOG_ERROR(...)
|
||||
#define LOG_WARNING(...)
|
||||
#define RETURN_ERROR(...)
|
||||
#define RETURN_WARNING(...)
|
||||
#define ASSERT_RETURN(...)
|
||||
#define CHECK(...)
|
||||
#define ASSERT_RETURN_WARN(...)
|
||||
#define UNREACHABLE(...)
|
||||
|
||||
#else
|
||||
|
||||
#define LOG_INFO(...) do {\
|
||||
if(g_debug_log_lvl < 3) break;\
|
||||
printf("[%s:%d] INFO | ", __FILE__, __LINE__);\
|
||||
|
@ -85,6 +71,4 @@ extern int g_debug_log_lvl;
|
|||
abort();\
|
||||
} while(0)
|
||||
|
||||
#endif
|
||||
|
||||
#endif // !CUTES_DEBUG_H
|
||||
|
|
22
hash_map.c
22
hash_map.c
|
@ -42,23 +42,17 @@ void hash_map_insert(HashMap *self, void *key, void *value) {
|
|||
}
|
||||
|
||||
List hash_map_keys(HashMap *self) {
|
||||
List keys = list_from_type(void*);
|
||||
for(size_t bucket_index = 0; bucket_index < CUTES_HASH_MAP_BUCKETS; ++bucket_index) {
|
||||
for(size_t key_index = 0; key_index < self->buckets[bucket_index].len; ++key_index) {
|
||||
void *key = list_at(self->buckets + bucket_index, key_index) + sizeof(uintptr_t);
|
||||
list_add(&keys, &key);
|
||||
}
|
||||
}
|
||||
List keys = list_init(self->key_size);
|
||||
for(size_t bucket_index = 0; bucket_index < CUTES_HASH_MAP_BUCKETS; ++bucket_index)
|
||||
for(size_t key_index = 0; key_index < self->buckets[bucket_index].len; ++key_index)
|
||||
list_add(&keys, list_at(self->buckets + bucket_index, key_index));
|
||||
return keys;
|
||||
}
|
||||
|
||||
List hash_map_values(HashMap *self) {
|
||||
List values = list_from_type(void*);
|
||||
for(size_t bucket_index = 0; bucket_index < CUTES_HASH_MAP_BUCKETS; ++bucket_index) {
|
||||
for(size_t value_index = 0; value_index < self->buckets[bucket_index].len; ++value_index) {
|
||||
void *value = ((char*)list_at(self->buckets + bucket_index, value_index)) + (sizeof(uintptr_t) + self->key_size);
|
||||
list_add(&values, &value);
|
||||
}
|
||||
}
|
||||
List values = list_init(self->value_size);
|
||||
for(size_t bucket_index = 0; bucket_index < CUTES_HASH_MAP_BUCKETS; ++bucket_index)
|
||||
for(size_t value_index = 0; value_index < self->buckets[bucket_index].len; ++value_index)
|
||||
list_add(&values, ((char*)list_at(self->buckets + bucket_index, value_index)) + (sizeof(uintptr_t) + self->key_size));
|
||||
return values;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue