initial hashmap code

This commit is contained in:
2024-11-09 19:58:58 +01:00
parent 2f39ca6fc1
commit 51a309e55f
16 changed files with 172 additions and 87 deletions

9
src/hashmap.c Normal file
View File

@@ -0,0 +1,9 @@
#include "hashmap.h"
int hash(int sockfd) { return sockfd % HASHMAP_MAX_ITEMS; }
void hm_insert(struct hashmap *map, int sockfd, struct sockaddr_storage *sas) {
int index = hash(sockfd);
map[index].sockfd = sockfd;
map[index].sas = *sas;
}