Memory cleanup

This commit is contained in:
angt
2016-02-02 21:36:17 +01:00
parent 6561f819f9
commit 0ce0243f85

20
mud.c
View File

@@ -297,6 +297,26 @@ struct mud *mud_create (void)
void mud_delete (struct mud *mud)
{
if (!mud)
return;
free(mud->tx.packet);
free(mud->rx.packet);
while (mud->sock) {
struct sock *sock = mud->sock;
if (sock->fd != -1)
close(sock->fd);
mud->sock = sock->next;
free(sock);
}
while (mud->path) {
struct path *path = mud->path;
mud->path = path->next;
free(path);
}
free(mud);
}