There shouldn't be any memory leak anymore, and it's now super fast.

This commit is contained in:
2025-05-17 18:49:22 +02:00
parent 14279b5c06
commit 4cec4644fa
7 changed files with 169 additions and 92 deletions
+2 -2
View File
@@ -20,14 +20,14 @@ class ServerUtils {
static void send_data(int client_fd, const string& data);
static void send_image(int client_fd, const string& path, image_type type);
static size_t send_all(int client_fd, const char* data, size_t length);
static string get_ip(int client_fd);
static uint32_t get_ip_2(int client_fd);
};
const string HTML_RESPONSE_HEADER =
"HTTP/1.1 200 OK\r\n"
"Content-Type: text/html; charset=utf-8\r\n"
"Transfer-Encoding: chunked\r\n"
//"Cache-control: max-age=12000\r\n"
"Cache-control: max-age=12000\r\n"
"Connection: close\r\n\r\n";
const string CSS_RESPONSE_HEADER =
+1 -1
View File
@@ -5,7 +5,7 @@
using namespace std;
struct Track {
string Ip;
uint32_t Ip;
string UserAgent;
};
+2
View File
@@ -12,6 +12,7 @@ struct WordUtils {
static unordered_map<string, unordered_map<string, int>> load_data(const string& path);
static vector<string> load_css(const string& path);
static vector<string> predict_next_word(const string& input, const unordered_map<string, unordered_map<string, int>>& word_frequencies, size_t count);
static vector<string> predict_next_word_2(const string& input, const unordered_map<string, unordered_map<string, int>>& word_frequencies, size_t count);
static string load_file(const string& path);
static vector<string> split_string(const string& input, data_type type);
static string extract_url(const string& input);
@@ -19,6 +20,7 @@ struct WordUtils {
static bool contains_image(const string& input);
static string extract_image_name(const string& input);
static string create_tag(const unordered_map<string, unordered_map<string, int>>& word_frequencies, const char& hash);
static string create_tag_2(const unordered_map<string, unordered_map<string, int>>& word_frequencies, const char& hash);
static string create_link(const unordered_map<string, unordered_map<string, int>>& word_frequencies, unsigned long hash);
static string create_image(const string& image);
static unsigned int hash_url(const string& input);