Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions client_ftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,15 @@ int main(int argc, char* argv[])
fprintf(stderr, "Wrong path.\n");
break;
case EXIT:
{
freecommand(cmd);
goto outside_client_command_loop;
}
default:
// display error
break;
}
freecommand(cmd);
}
outside_client_command_loop:

Expand Down
1 change: 1 addition & 0 deletions client_ftp.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ struct command
struct command* userinputtocommand(char [LENUSERINPUT]);

void printcommand(struct command*);
void freecommand(struct command*);

void command_pwd(struct packet*, struct packet*, int);
void command_lcd(char*);
Expand Down
14 changes: 14 additions & 0 deletions client_ftp_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,20 @@ void printcommand(struct command* c)
printf("\n");
}

void freecommand(struct command* c)
{
if (c->npaths > 0)
{
int i;
// free strings
for(i = 0; i < c->npaths; i++)
free(c->paths[i]);
free(c->paths);
}
free(c);
}


void command_pwd(struct packet* chp, struct packet* data, int sfd_client)
{
int x;
Expand Down