In the thread_fn function, you allocate memory for tempReq using malloc, but you never free it. you can add free(tempReq) before returning from the function to ensure that memory allocated for tempReq is released when no longer needed.
char *tempReq = (char*)malloc(strlen(buffer) * sizeof(char) + 1);
// Copy buffer content to tempReq
for (int i = 0; i < strlen(buffer); i++) {
tempReq[i] = buffer[i];
}
tempReq[strlen(buffer)] = '\0'; // Null-terminate the string
// Handle request, cache operations, etc.
// Free dynamically allocated memory for tempReq
free(tempReq);
// Close socket and perform other cleanup
In the thread_fn function, you allocate memory for tempReq using malloc, but you never free it. you can add free(tempReq) before returning from the function to ensure that memory allocated for tempReq is released when no longer needed.