X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=stat.cpp;h=1797536ca9ee20bbb2fcb6c4df7cd7fa4ee3c133;hp=1e171e8b97fa563ed73da40badb2706afd730925;hb=95d232ca7285b49ce1bdccbe81c2c444c68e1c4d;hpb=65362d93aa4678209bfeeba92fb5aa41f5955777 diff --git a/stat.cpp b/stat.cpp index 1e171e8..1797536 100644 --- a/stat.cpp +++ b/stat.cpp @@ -10,10 +10,10 @@ */ char *stat_mem_strdup(const char *src, bool empty) { size_t len = 0; - char *ptr = NULL; + char *ptr = nullptr; if (!src) - return NULL; + return nullptr; len = strlen(src); if ((!empty ? len : true) && (ptr = (char*)mem_a(len + 1))) { @@ -30,7 +30,7 @@ char *stat_mem_strdup(const char *src, bool empty) { void _util_vec_grow(void **a, size_t i, size_t s) { vector_t *d = vec_meta(*a); size_t m = 0; - void *p = NULL; + void *p = nullptr; if (*a) { m = 2 * d->allocated + i; @@ -55,11 +55,11 @@ void _util_vec_delete(void *data) { * all around. This is the internal interface, please look for * EXPOSED INTERFACE comment below */ -typedef struct hash_node_t { - char *key; /* the key for this node in table */ - void *value; /* pointer to the data as void* */ - struct hash_node_t *next; /* next node (linked list) */ -} hash_node_t; +struct hash_node_t { + char *key; /* the key for this node in table */ + void *value; /* pointer to the data as void* */ + hash_node_t *next; /* next node (linked list) */ +}; size_t hash(const char *key); @@ -70,15 +70,15 @@ size_t util_hthash(hash_table_t *ht, const char *key) { static hash_node_t *_util_htnewpair(const char *key, void *value) { hash_node_t *node; if (!(node = (hash_node_t*)mem_a(sizeof(hash_node_t)))) - return NULL; + return nullptr; if (!(node->key = util_strdupe(key))) { mem_d(node); - return NULL; + return nullptr; } node->value = value; - node->next = NULL; + node->next = nullptr; return node; } @@ -91,17 +91,17 @@ static hash_node_t *_util_htnewpair(const char *key, void *value) { * util_htdel(table) -- to delete the table */ hash_table_t *util_htnew(size_t size) { - hash_table_t *hashtable = NULL; + hash_table_t *hashtable = nullptr; if (size < 1) - return NULL; + return nullptr; if (!(hashtable = (hash_table_t*)mem_a(sizeof(hash_table_t)))) - return NULL; + return nullptr; if (!(hashtable->table = (hash_node_t**)mem_a(sizeof(hash_node_t*) * size))) { mem_d(hashtable); - return NULL; + return nullptr; } hashtable->size = size; @@ -111,9 +111,9 @@ hash_table_t *util_htnew(size_t size) { } void util_htseth(hash_table_t *ht, const char *key, size_t bin, void *value) { - hash_node_t *newnode = NULL; - hash_node_t *next = NULL; - hash_node_t *last = NULL; + hash_node_t *newnode = nullptr; + hash_node_t *next = nullptr; + hash_node_t *last = nullptr; next = ht->table[bin]; @@ -149,7 +149,7 @@ void *util_htgeth(hash_table_t *ht, const char *key, size_t bin) { pair = pair->next; if (!pair || !pair->key || strcmp(key, pair->key) != 0) - return NULL; + return nullptr; return pair->value; } @@ -178,7 +178,7 @@ void *code_util_str_htgeth(hash_table_t *ht, const char *key, size_t bin) { if (cmp == 0) return pair->value; if (cmp < 0) - return NULL; + return nullptr; pair = pair->next; continue; } @@ -190,7 +190,7 @@ void *code_util_str_htgeth(hash_table_t *ht, const char *key, size_t bin) { } pair = pair->next; } - return NULL; + return nullptr; } /* @@ -245,5 +245,5 @@ void util_htrm(hash_table_t *ht, const char *key, void (*cb)(void*)) { } void util_htdel(hash_table_t *ht) { - util_htrem(ht, NULL); + util_htrem(ht, nullptr); }