aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-09-24 09:07:00 +0000
committerRoy Marples <roy@marples.name>2007-09-24 09:07:00 +0000
commit495690ea5e01c1375a8bd8106ba5fbaea634444c (patch)
treec244894d2a3abe0d67fb30b1545add582b045013 /src
parent7a2507c52fcef007636701b947d0106c5b968272 (diff)
Plug some leaks
Diffstat (limited to 'src')
-rw-r--r--src/librc-daemon.c7
-rw-r--r--src/mountinfo.c28
-rw-r--r--src/rc.c5
3 files changed, 17 insertions, 23 deletions
diff --git a/src/librc-daemon.c b/src/librc-daemon.c
index a563797b..5b1e0239 100644
--- a/src/librc-daemon.c
+++ b/src/librc-daemon.c
@@ -341,9 +341,8 @@ void rc_set_service_daemon (const char *service, const char *exec,
oldfile = ffile;
}
}
- if (ffile)
- free (ffile);
- free (files);
+ free (ffile);
+ rc_strlist_free (files);
}
/* Now store our daemon info */
@@ -413,7 +412,7 @@ bool rc_service_started_daemon (const char *service, const char *exec,
if (retval)
break;
}
- free (files);
+ rc_strlist_free (files);
}
free (mexec);
diff --git a/src/mountinfo.c b/src/mountinfo.c
index c55a942b..2b361d14 100644
--- a/src/mountinfo.c
+++ b/src/mountinfo.c
@@ -230,7 +230,7 @@ static char **find_mounts (struct args *args)
# error "Operating system not supported!"
#endif
-static regex_t *get_regex (char *string)
+static regex_t *get_regex (const char *string)
{
regex_t *reg = rc_xmalloc (sizeof (regex_t));
int result;
@@ -279,6 +279,8 @@ int mountinfo (int argc, char **argv)
#define DO_REG(_var) \
if (_var) free (_var); \
_var = get_regex (optarg);
+#define REG_FREE(_var) \
+ if (_var) { regfree (_var); free (_var); }
memset (&args, 0, sizeof (struct args));
args.mount_type = mount_to;
@@ -333,18 +335,12 @@ int mountinfo (int argc, char **argv)
nodes = find_mounts (&args);
- if (args.fstype_regex)
- regfree (args.fstype_regex);
- if (args.skip_fstype_regex)
- regfree (args.skip_fstype_regex);
- if (args.node_regex)
- regfree (args.node_regex);
- if (args.skip_node_regex)
- regfree (args.skip_node_regex);
- if (args.options_regex)
- regfree (args.options_regex);
- if (args.skip_options_regex)
- regfree (args.skip_options_regex);
+ REG_FREE (args.fstype_regex);
+ REG_FREE (args.skip_fstype_regex);
+ REG_FREE (args.node_regex);
+ REG_FREE (args.skip_node_regex);
+ REG_FREE (args.options_regex);
+ REG_FREE (args.skip_options_regex);
rc_strlist_reverse (nodes);
@@ -360,10 +356,8 @@ int mountinfo (int argc, char **argv)
}
rc_strlist_free (nodes);
- if (point_regex)
- regfree (point_regex);
- if (skip_point_regex)
- regfree (skip_point_regex);
+ REG_FREE (point_regex);
+ REG_FREE (skip_point_regex);
exit (result);
}
diff --git a/src/rc.c b/src/rc.c
index 850be074..2ae3d560 100644
--- a/src/rc.c
+++ b/src/rc.c
@@ -1140,8 +1140,9 @@ int main (int argc, char **argv)
CHAR_FREE (tmp);
} else {
/* Store our list of coldplugged services */
- rc_strlist_join (&coldplugged_services,
- rc_ls_dir (RC_SVCDIR_COLDPLUGGED, RC_LS_INITD));
+ tmplist = rc_ls_dir (RC_SVCDIR_COLDPLUGGED, RC_LS_INITD);
+ rc_strlist_join (&coldplugged_services, tmplist);
+ rc_strlist_free (tmplist);
if (strcmp (newlevel ? newlevel : runlevel, RC_LEVEL_SINGLE) != 0 &&
strcmp (newlevel ? newlevel : runlevel, RC_LEVEL_SHUTDOWN) != 0 &&
strcmp (newlevel ? newlevel : runlevel, RC_LEVEL_REBOOT) != 0)