fix hashmap
This commit is contained in:
@@ -14,19 +14,46 @@ struct hashmap {
|
||||
struct hashmap *next;
|
||||
};
|
||||
|
||||
/* Calculate the hash code of a file descriptor */
|
||||
/**
|
||||
* @brief Calculates the hash code of a given file descriptor
|
||||
*
|
||||
* @param sockfd[in] The file descriptor
|
||||
* @return int Returns the hash code
|
||||
*/
|
||||
int hash(int sockfd);
|
||||
|
||||
/* Initialize the hash map */
|
||||
/**
|
||||
* @brief Initializes the hash map
|
||||
*
|
||||
* @param map[out] The hash map uninitialized
|
||||
*/
|
||||
void hm_init(struct hashmap *map);
|
||||
|
||||
/* Insert a new key in the hash map */
|
||||
void hm_insert(struct hashmap *map, int sockfd, struct sockaddr_storage *sas);
|
||||
/**
|
||||
* @brief Inserts a key in the hash map
|
||||
*
|
||||
* @param map[out] The hash map
|
||||
* @param sockfd[in] The file descriptor (value)
|
||||
* @param sas[in] The sockaddr (value)
|
||||
*/
|
||||
void hm_push(struct hashmap *map, int sockfd, struct sockaddr_storage *sas);
|
||||
|
||||
/* Search for a key in the hash map */
|
||||
/**
|
||||
* @brief Searches for a key in the hash map
|
||||
*
|
||||
* @param map[in] The hash map
|
||||
* @param sockfd[in] The file descriptor (key)
|
||||
* @return struct hashmap* Returns NULL or the key pointer
|
||||
*/
|
||||
struct hashmap *hm_lookup(struct hashmap *map, int sockfd);
|
||||
|
||||
/* Clean up the hash map */
|
||||
/**
|
||||
* @brief Cleans the hash map
|
||||
*
|
||||
* @param map[out] The hash map
|
||||
*/
|
||||
void hm_free(struct hashmap *map);
|
||||
|
||||
void hm_insert(struct hashmap *map, int sockfd, struct sockaddr_storage *sas);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user