Reversed the order of file manipulation functions, which fixed the 'Corrupted top size' error

master
Aadhavan Srinivasan 2 years ago
parent 768d3fcedf
commit a5ac16f884

@ -36,8 +36,9 @@ int main() {
User* dest_users[MAX_CONNECTIONS] = {NULL};
FD_ZERO(&read_fd_set);
char buffer[BUFFER_SIZE];
users = create_user_list("user_file.txt");
num_users = num_of_lines("user_file.txt");
users = create_user_list("user_file.txt");
struct sockaddr addr_struct;
int server_sock = create_local(4,'T',"127.0.0.1",30000,&addr_struct);
@ -131,7 +132,7 @@ User** create_user_list(char* filename) {
User** users = malloc (num_users * sizeof(User*));
token = strtok(file_str," \r\n");
for (int i=0;i<num_users-1;i++) {
for (int i=0;i<num_users;i++) {
users[i]->username = strdup(token);
token = strtok(NULL," \r\n");
users[i]->password = strdup(token);

Loading…
Cancel
Save