Browse files

Added initial freeing of used memory.

  • Loading branch information...
1 parent 4b050f6 commit 46f1c704c7a4aacb0c84f55500b593cedb2bfd7d @kse committed Jun 10, 2011
Showing with 15 additions and 0 deletions.
  1. +3 −0 src/runvpn.c
  2. +1 −0 src/runvpn.h
  3. +11 −0 src/vpn.c
View
3 src/runvpn.c
@@ -100,6 +100,7 @@ main(int argc, char *argv[])
vpn_status(&vpn);
vpn_start(&vpn, NO_DAEMON);
+ vpn_free(&vpn);
} else if (argc == 3) {
struct vpn vpn;
@@ -131,6 +132,8 @@ main(int argc, char *argv[])
} else {
fprintf(stderr, "Unknown action '%s'\n", argument);
}
+
+ vpn_free(&vpn);
}
return EXIT_SUCCESS;
View
1 src/runvpn.h
@@ -33,6 +33,7 @@ struct vpn {
};
int vpn_init(struct vpn *vpn, const char *folder, const char *name);
+void vpn_free(struct vpn *vpn);
enum vpn_status vpn_status(struct vpn *vpn);
int vpn_start(struct vpn *vpn, int daemon);
int vpn_stop(struct vpn *vpn);
View
11 src/vpn.c
@@ -12,6 +12,17 @@
#include "runvpn.h"
+void
+vpn_free(struct vpn *vpn)
+{
+ free(vpn->name);
+ free(vpn->path);
+ free(vpn->config);
+ free(vpn->log);
+ free(vpn->pid_file);
+ free(vpn);
+}
+
static void
chomp(char *string)
{

0 comments on commit 46f1c70

Please sign in to comment.