Compare commits
2 Commits
af50174b71
...
2021092a17
Author | SHA1 | Date |
---|---|---|
Sara | 2021092a17 | |
Sara | bb6dcbeabe |
16
debug.h
16
debug.h
|
@ -11,6 +11,20 @@
|
|||
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__);\
|
||||
|
@ -71,4 +85,6 @@ extern int g_debug_log_lvl;
|
|||
abort();\
|
||||
} while(0)
|
||||
|
||||
#endif
|
||||
|
||||
#endif // !CUTES_DEBUG_H
|
||||
|
|
22
hash_map.c
22
hash_map.c
|
@ -42,17 +42,23 @@ void hash_map_insert(HashMap *self, void *key, void *value) {
|
|||
}
|
||||
|
||||
List hash_map_keys(HashMap *self) {
|
||||
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));
|
||||
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);
|
||||
}
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
List hash_map_values(HashMap *self) {
|
||||
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));
|
||||
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);
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue