improve hash maps

This commit is contained in:
2025-05-03 18:01:50 +02:00
parent ad21ec0fa4
commit 8e880f59be
6 changed files with 88 additions and 9 deletions

View File

@@ -27,8 +27,6 @@
#define CWS_LOG_DEBUG(msg, ...)
#endif
#define CWS_LOG(level, msg, ...)
#define CWS_LOG_ERROR(msg, ...) fprintf(stderr, _ERR " " msg "\n", ##__VA_ARGS__)
#define CWS_LOG_WARNING(msg, ...) fprintf(stdout, _WARNING " " msg "\n", ##__VA_ARGS__)
#define CWS_LOG_INFO(msg, ...) fprintf(stdout, _INFO " " msg "\n", ##__VA_ARGS__)

View File

@@ -95,8 +95,12 @@ bool cws_hm_set(cws_hashmap *hashmap, void *key, void *value);
cws_bucket *cws_hm_get(cws_hashmap *hashmap, void *key);
/**
* TODO: Implement cws_hm_remove()
* @brief Removes a key-value pair from the hash map
*
* @param[in] hashmap Pointer to the hash map
* @param[in] key Pointer to the key to remove, this pointer will be freed so pay attention
* @return False if the key is not found, otherwise true
*/
bool cws_hm_remove(cws_hashmap *hashmap, void *key);
#endif

View File

@@ -24,7 +24,12 @@ void cws_utils_print_ips(const char *hostname, const char *port);
*/
void cws_utils_get_client_ip(struct sockaddr_storage *sa, char *ip);
/* TODO: add docs */
/**
* @brief Remove whitespaces from a string
*
* @param[in] str The string pointer
* @return Returns the new string without whitespaces
*/
char *cws_strip(char *str);
/* Functions used for hash maps */