From e3bc6666d6d5bd8922ca10652a2d04577357fa71 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Thu, 11 Oct 2007 23:17:53 +0000 Subject: malloc data size, not pointer size --- src/librc-daemon.c | 10 +++++----- src/librc-misc.c | 2 +- src/rc-misc.c | 24 ++++++++++++------------ src/rc.c | 8 ++++---- src/runscript.c | 6 +++--- 5 files changed, 25 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/librc-daemon.c b/src/librc-daemon.c index 112f4c9c..80e5b162 100644 --- a/src/librc-daemon.c +++ b/src/librc-daemon.c @@ -311,21 +311,21 @@ bool rc_service_daemon_set (const char *service, const char *exec, if (exec) { i = strlen (exec) + 6; - mexec = xmalloc (sizeof (char *) * i); + mexec = xmalloc (sizeof (char) * i); snprintf (mexec, i, "exec=%s", exec); } else mexec = xstrdup ("exec="); if (name) { i = strlen (name) + 6; - mname = xmalloc (sizeof (char *) * i); + mname = xmalloc (sizeof (char) * i); snprintf (mname, i, "name=%s", name); } else mname = xstrdup ("name="); if (pidfile) { i = strlen (pidfile) + 9; - mpidfile = xmalloc (sizeof (char *) * i); + mpidfile = xmalloc (sizeof (char) * i); snprintf (mpidfile, i, "pidfile=%s", pidfile); } else mpidfile = xstrdup ("pidfile="); @@ -404,11 +404,11 @@ bool rc_service_started_daemon (const char *service, const char *exec, free (svc); i = strlen (exec) + 6; - mexec = xmalloc (sizeof (char *) * i); + mexec = xmalloc (sizeof (char) * i); snprintf (mexec, i, "exec=%s", exec); if (indx > 0) { - int len = sizeof (char *) * 10; + int len = sizeof (char) * 10; file = xmalloc (len); snprintf (file, len, "%03d", indx); retval = _match_daemon (dirpath, file, mexec, NULL, NULL); diff --git a/src/librc-misc.c b/src/librc-misc.c index 6d90b02c..d5b66b02 100644 --- a/src/librc-misc.c +++ b/src/librc-misc.c @@ -58,7 +58,7 @@ char *rc_strcatpaths (const char *path1, const char *paths, ...) } va_end (ap); - pathp = path = xmalloc (length * sizeof (char *)); + pathp = path = xmalloc (length * sizeof (char)); memset (path, 0, length); i = strlen (path1); memcpy (path, path1, i); diff --git a/src/rc-misc.c b/src/rc-misc.c index a23effd5..60f8009a 100644 --- a/src/rc-misc.c +++ b/src/rc-misc.c @@ -68,7 +68,7 @@ char **env_filter (void) if (! env_var && profile) { env_len = strlen (env_name) + strlen ("export ") + 1; - p = xmalloc (sizeof (char *) * env_len); + p = xmalloc (sizeof (char) * env_len); snprintf (p, env_len, "export %s", env_name); env_var = rc_config_value (profile, p); free (p); @@ -84,7 +84,7 @@ char **env_filter (void) { got_path = true; env_len = strlen (env_name) + strlen (env_var) + pplen + 2; - e = p = xmalloc (sizeof (char *) * env_len); + e = p = xmalloc (sizeof (char) * env_len); p += snprintf (e, env_len, "%s=%s", env_name, PATH_PREFIX); /* Now go through the env var and only add bits not in our PREFIX */ @@ -103,7 +103,7 @@ char **env_filter (void) *p++ = 0; } else { env_len = strlen (env_name) + strlen (env_var) + 2; - e = xmalloc (sizeof (char *) * env_len); + e = xmalloc (sizeof (char) * env_len); snprintf (e, env_len, "%s=%s", env_name, env_var); } @@ -115,7 +115,7 @@ char **env_filter (void) However, we do need a path, so use a default. */ if (! got_path) { env_len = strlen ("PATH=") + strlen (PATH_PREFIX) + 2; - p = xmalloc (sizeof (char *) * env_len); + p = xmalloc (sizeof (char) * env_len); snprintf (p, env_len, "PATH=%s", PATH_PREFIX); rc_strlist_add (&env, p); free (p); @@ -197,7 +197,7 @@ char **env_config (void) rc_strlist_add (&env, line); } else { int len = strlen (line) + strlen (e) + 2; - char *new = xmalloc (sizeof (char *) * len); + char *new = xmalloc (sizeof (char) * len); snprintf (new, len, "%s=%s", line, e); rc_strlist_add (&env, new); free (new); @@ -207,14 +207,14 @@ char **env_config (void) /* One char less to drop the trailing / */ i = strlen ("RC_LIBDIR=") + strlen (RC_LIBDIR) + 1; - line = xmalloc (sizeof (char *) * i); + line = xmalloc (sizeof (char) * i); snprintf (line, i, "RC_LIBDIR=" RC_LIBDIR); rc_strlist_add (&env, line); free (line); /* One char less to drop the trailing / */ i = strlen ("RC_SVCDIR=") + strlen (RC_SVCDIR) + 1; - line = xmalloc (sizeof (char *) * i); + line = xmalloc (sizeof (char) * i); snprintf (line, i, "RC_SVCDIR=" RC_SVCDIR); rc_strlist_add (&env, line); free (line); @@ -222,7 +222,7 @@ char **env_config (void) rc_strlist_add (&env, "RC_BOOTLEVEL=" RC_LEVEL_BOOT); i = strlen ("RC_SOFTLEVEL=") + strlen (runlevel) + 1; - line = xmalloc (sizeof (char *) * i); + line = xmalloc (sizeof (char) * i); snprintf (line, i, "RC_SOFTLEVEL=%s", runlevel); rc_strlist_add (&env, line); free (line); @@ -234,7 +234,7 @@ char **env_config (void) if (buffer[i] == '\n') buffer[i] = 0; i += strlen ("RC_DEFAULTLEVEL=") + 2; - line = xmalloc (sizeof (char *) * i); + line = xmalloc (sizeof (char) * i); snprintf (line, i, "RC_DEFAULTLEVEL=%s", buffer); rc_strlist_add (&env, line); free (line); @@ -267,7 +267,7 @@ char **env_config (void) if (sys[0]) { i = strlen ("RC_SYS=") + strlen (sys) + 2; - line = xmalloc (sizeof (char *) * i); + line = xmalloc (sizeof (char) * i); snprintf (line, i, "RC_SYS=%s", sys); rc_strlist_add (&env, line); free (line); @@ -284,7 +284,7 @@ char **env_config (void) if (! has_net_fs_list) { i = strlen ("RC_NET_FS_LIST=") + strlen (RC_NET_FS_LIST_DEFAULT) + 1; - line = xmalloc (sizeof (char *) * i); + line = xmalloc (sizeof (char) * i); snprintf (line, i, "RC_NET_FS_LIST=%s", RC_NET_FS_LIST_DEFAULT); rc_strlist_add (&env, line); free (line); @@ -294,7 +294,7 @@ char **env_config (void) To save on calling uname, we store it in an environment variable */ if (uname (&uts) == 0) { i = strlen ("RC_UNAME=") + strlen (uts.sysname) + 2; - line = xmalloc (sizeof (char *) * i); + line = xmalloc (sizeof (char) * i); snprintf (line, i, "RC_UNAME=%s", uts.sysname); rc_strlist_add (&env, line); free (line); diff --git a/src/rc.c b/src/rc.c index c236bd50..0f21fe86 100644 --- a/src/rc.c +++ b/src/rc.c @@ -1105,7 +1105,7 @@ int main (int argc, char **argv) if ((dp = opendir ("/dev/net"))) { while ((d = readdir (dp))) { i = (strlen ("net.") + strlen (d->d_name) + 1); - tmp = xmalloc (sizeof (char *) * i); + tmp = xmalloc (sizeof (char) * i); snprintf (tmp, i, "net.%s", d->d_name); if (rc_service_exists (tmp) && rc_service_plugable (tmp)) @@ -1126,7 +1126,7 @@ int main (int argc, char **argv) char *p = d->d_name + 3; if (p && isdigit (*p)) { i = (strlen ("moused.") + strlen (d->d_name) + 1); - tmp = xmalloc (sizeof (char *) * i); + tmp = xmalloc (sizeof (char) * i); snprintf (tmp, i, "moused.%s", d->d_name); if (rc_service_exists (tmp) && rc_service_plugable (tmp)) rc_service_mark (tmp, RC_SERVICE_COLDPLUGGED); @@ -1246,7 +1246,7 @@ int main (int argc, char **argv) continue; len = strlen (service) + strlen (runlevel) + 2; - tmp = xmalloc (sizeof (char *) * len); + tmp = xmalloc (sizeof (char) * len); snprintf (tmp, len, "%s.%s", service, runlevel); conf = rc_strcatpaths (RC_CONFDIR, tmp, (char *) NULL); found = exists (conf); @@ -1254,7 +1254,7 @@ int main (int argc, char **argv) CHAR_FREE (tmp); if (! found) { len = strlen (service) + strlen (newlevel) + 2; - tmp = xmalloc (sizeof (char *) * len); + tmp = xmalloc (sizeof (char) * len); snprintf (tmp, len, "%s.%s", service, newlevel); conf = rc_strcatpaths (RC_CONFDIR, tmp, (char *) NULL); found = exists (conf); diff --git a/src/runscript.c b/src/runscript.c index 74a84c00..ee49be7e 100644 --- a/src/runscript.c +++ b/src/runscript.c @@ -523,7 +523,7 @@ static void make_exclusive () path = rc_strcatpaths (RC_SVCDIR, "exclusive", applet, (char *) NULL); i = strlen (path) + 16; - mtime_test = xmalloc (sizeof (char *) * i); + mtime_test = xmalloc (sizeof (char) * i); snprintf (mtime_test, i, "%s.%d", path, getpid ()); free (path); @@ -730,7 +730,7 @@ static void svc_start (bool deps) } len += 5; - tmp = xmalloc (sizeof (char *) * len); + tmp = xmalloc (sizeof (char) * len); p = tmp; STRLIST_FOREACH (tmplist, svc, i) { if (i > 1) { @@ -1117,7 +1117,7 @@ int runscript (int argc, char **argv) } /* Make our prefix string */ - prefix = xmalloc (sizeof (char *) * l); + prefix = xmalloc (sizeof (char) * l); ll = strlen (applet); memcpy (prefix, applet, ll); memset (prefix + ll, ' ', l - ll); -- cgit v1.2.3