summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoît Dejean <bdejean@src.gnome.org>2004-06-06 21:23:56 +0000
committerBenoît Dejean <bdejean@src.gnome.org>2004-06-06 21:23:56 +0000
commitfe494bc8468da22a62f5c0a3defd53b40fc39fdc (patch)
tree7942655bdabc22c585a13a8b4020c03b4bb5579f
parent7de929d2d7110ee787426de0dfed11de38e92097 (diff)
downloadlibgtop-fe494bc8468da22a62f5c0a3defd53b40fc39fdc.tar.gz
Removed useless tests. Replace g_malloc + memset by g_malloc0 Replace
* proclist.c: (glibtop_get_proclist_s): Removed useless tests. * procmap.c: (glibtop_get_proc_map_s): Replace g_malloc + memset by g_malloc0 * procstate.c: (glibtop_get_proc_state_s): Replace strncpy by g_strlcpy.
-rw-r--r--sysdeps/solaris/ChangeLog7
-rw-r--r--sysdeps/solaris/proclist.c3
-rw-r--r--sysdeps/solaris/procmap.c5
-rw-r--r--sysdeps/solaris/procstate.c2
4 files changed, 10 insertions, 7 deletions
diff --git a/sysdeps/solaris/ChangeLog b/sysdeps/solaris/ChangeLog
index 30e6bfcc..73fb6eb4 100644
--- a/sysdeps/solaris/ChangeLog
+++ b/sysdeps/solaris/ChangeLog
@@ -1,3 +1,10 @@
+2004-06-06 Benoît Dejean <tazforever@dlfp.org>
+
+ * proclist.c: (glibtop_get_proclist_s): Removed useless tests.
+ * procmap.c: (glibtop_get_proc_map_s): Replace g_malloc + memset
+ by g_malloc0
+ * procstate.c: (glibtop_get_proc_state_s): Replace strncpy by g_strlcpy.
+
2004-05-25 Benoît Dejean <tazforever@dlfp.org>
* loadavg.c: (glibtop_get_loadavg_s):
diff --git a/sysdeps/solaris/proclist.c b/sysdeps/solaris/proclist.c
index ec78a339..32053972 100644
--- a/sysdeps/solaris/proclist.c
+++ b/sysdeps/solaris/proclist.c
@@ -96,8 +96,7 @@ glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf,
if(s_stat(buffer, &statb) < 0)
return NULL;
}
- if(!(pids_chain = g_malloc(sizeof(unsigned))))
- return NULL;
+ pids_chain = g_malloc(sizeof(unsigned));
*pids_chain = pid;
return pids_chain;
}
diff --git a/sysdeps/solaris/procmap.c b/sysdeps/solaris/procmap.c
index f6196b7b..2cd99bb0 100644
--- a/sysdeps/solaris/procmap.c
+++ b/sysdeps/solaris/procmap.c
@@ -120,13 +120,10 @@ glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid)
return NULL;
}
#endif
- if(!(entry = g_malloc(nmaps * sizeof(glibtop_map_entry))))
- return NULL;
buf->number = nmaps;
buf->size = sizeof(glibtop_map_entry);
buf->total = nmaps * sizeof(glibtop_map_entry);
-
- memset(entry, 0, nmaps * sizeof(glibtop_map_entry));
+ entry = g_malloc0(buf->total);
#if GLIBTOP_SOLARIS_RELEASE >= 560
diff --git a/sysdeps/solaris/procstate.c b/sysdeps/solaris/procstate.c
index 89647d22..01323085 100644
--- a/sysdeps/solaris/procstate.c
+++ b/sysdeps/solaris/procstate.c
@@ -116,7 +116,7 @@ glibtop_get_proc_state_s (glibtop *server, glibtop_proc_state *buf, pid_t pid)
#if (LIBGTOP_VERSION_CODE >= 1001002) && defined(HAVE_PROCFS_H)
buf->last_processor = psinfo.pr_lwp.pr_onpro;
#endif
- strncpy (buf->cmd, psinfo.pr_fname, 39);
+ g_strlcpy (buf->cmd, psinfo.pr_fname, sizeof buf->cmd);
buf->flags = _glibtop_sysdeps_proc_state;
}