move self_path to the base sigar_t

This commit is contained in:
Doug MacEachern 2005-12-14 18:35:19 +00:00
parent 9166277502
commit dc3eceb517
4 changed files with 10 additions and 9 deletions

View File

@ -36,7 +36,8 @@
sigar_pid_t pid; \
char errbuf[256]; \
char *ifconf_buf; \
int ifconf_len
int ifconf_len; \
char *self_path
#if defined(WIN32)
# define SIGAR_INLINE __inline

View File

@ -164,8 +164,6 @@ int sigar_os_open(sigar_t **sigar)
(*sigar)->model[0] = '\0';
(*sigar)->self_path[0] = '\0';
uname(&name);
(*sigar)->aix_version = atoi(name.version);
@ -231,7 +229,7 @@ static int proc_module_get_self(void *data, char *name, int len)
if (strnEQ(ptr+1, "libsigar-", 9)) {
*ptr = '\0'; /* chop libsigar-powerpc-ibm-aix-4.3.x.so */
SIGAR_SSTRCPY(sigar->self_path, name);
sigar->self_path = sigar_strdup(name);
if (SIGAR_LOG_IS_DEBUG(sigar)) {
sigar_log_printf(sigar, SIGAR_LOG_DEBUG,
@ -247,7 +245,7 @@ static int proc_module_get_self(void *data, char *name, int len)
static char *sigar_get_self_path(sigar_t *sigar)
{
if (sigar->self_path[0] == '\0') {
if (!sigar->self_path) {
sigar_proc_modules_t procmods;
procmods.module_getter = proc_module_get_self;
procmods.data = sigar;
@ -255,9 +253,9 @@ static char *sigar_get_self_path(sigar_t *sigar)
sigar_proc_modules_get(sigar, sigar_pid_get(sigar),
&procmods);
if (sigar->self_path[0] == '\0') {
if (!sigar->self_path) {
/* dont try again */
SIGAR_SSTRCPY(sigar->self_path, ".");
sigar->self_path = sigar_strdup(".");
}
}

View File

@ -72,7 +72,6 @@ struct sigar_t {
int cpuinfo_size;
int cpu_mhz;
char model[128];
char self_path[SIGAR_PATH_MAX]; /* path to where libsigar.so lives */
int aix_version;
int thrusage;
sigar_cache_t *diskmap;

View File

@ -21,6 +21,7 @@ SIGAR_DECLARE(int) sigar_open(sigar_t **sigar)
(*sigar)->log_level = -1; /* log nothing by default */
(*sigar)->log_impl = NULL;
(*sigar)->log_data = NULL;
(*sigar)->self_path = NULL;
}
return status;
@ -31,7 +32,9 @@ SIGAR_DECLARE(int) sigar_close(sigar_t *sigar)
if (sigar->ifconf_buf) {
free(sigar->ifconf_buf);
}
if (sigar->self_path) {
free(sigar->self_path);
}
return sigar_os_close(sigar);
}