From 9ca64171c2b24e1395f611f9637efcbb82c16799 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Tue, 13 Dec 2005 01:18:30 +0000 Subject: [PATCH] move sigar_getword to sigar_util --- src/os/hpux/hpux_sigar.c | 27 --------------------------- src/os/solaris/solaris_sigar.c | 27 --------------------------- src/sigar_util.c | 26 ++++++++++++++++++++++++++ 3 files changed, 26 insertions(+), 54 deletions(-) diff --git a/src/os/hpux/hpux_sigar.c b/src/os/hpux/hpux_sigar.c index baccd60f..526de7ae 100644 --- a/src/os/hpux/hpux_sigar.c +++ b/src/os/hpux/hpux_sigar.c @@ -362,33 +362,6 @@ int sigar_proc_state_get(sigar_t *sigar, sigar_pid_t pid, return SIGAR_OK; } -/* XXX: could be useful elsewhere */ -static char *sigar_getword(char **line, char stop) -{ - char *pos = *line; - int len; - char *res; - - while ((*pos != stop) && *pos) { - ++pos; - } - - len = pos - *line; - res = (char *)malloc(len + 1); - memcpy(res, *line, len); - res[len] = 0; - - if (stop) { - while (*pos == stop) { - ++pos; - } - } - - *line = pos; - - return res; -} - /* * XXX: pst_cmd is only 64 chars of the command args. * according to HP forums there isn't a way to get them diff --git a/src/os/solaris/solaris_sigar.c b/src/os/solaris/solaris_sigar.c index 18bbea85..95f5ab4a 100644 --- a/src/os/solaris/solaris_sigar.c +++ b/src/os/solaris/solaris_sigar.c @@ -653,33 +653,6 @@ int sigar_proc_state_get(sigar_t *sigar, sigar_pid_t pid, return SIGAR_OK; } -/* XXX: copied from hpux_sigar */ -static char *sigar_getword(char **line, char stop) -{ - char *pos = *line; - int len; - char *res; - - while ((*pos != stop) && *pos) { - ++pos; - } - - len = pos - *line; - res = malloc(len + 1); - memcpy(res, *line, len); - res[len] = 0; - - if (stop) { - while (*pos == stop) { - ++pos; - } - } - - *line = pos; - - return res; -} - typedef struct { int timestamp; char *args; diff --git a/src/sigar_util.c b/src/sigar_util.c index d5cc2e83..524934fb 100644 --- a/src/sigar_util.c +++ b/src/sigar_util.c @@ -54,6 +54,32 @@ SIGAR_INLINE char *sigar_skip_multiple_token(char *p, int count) return p; } +char *sigar_getword(char **line, char stop) +{ + char *pos = *line; + int len; + char *res; + + while ((*pos != stop) && *pos) { + ++pos; + } + + len = pos - *line; + res = malloc(len + 1); + memcpy(res, *line, len); + res[len] = 0; + + if (stop) { + while (*pos == stop) { + ++pos; + } + } + + *line = pos; + + return res; +} + int sigar_file2str(const char *fname, char *buffer, int buflen) { int len;