diff --git a/include/sigar_private.h b/include/sigar_private.h index 8e6728bf..01b29046 100644 --- a/include/sigar_private.h +++ b/include/sigar_private.h @@ -12,6 +12,10 @@ #include #endif +#ifdef DMALLOC +#include +#endif + /* common to all os sigar_t's */ /* XXX: this is ugly; but don't want the same stuffs * duplicated on 4 platforms and am too lazy to change @@ -40,6 +44,15 @@ # define SIGAR_INLINE #endif +#ifdef DMALLOC +/* linux has its own strdup macro, make sure we use dmalloc's */ +#define sigar_strdup(s) \ + dmalloc_strdup(__FILE__, __LINE__, s, 0); +#else +#define sigar_strdup(s) \ + strdup(s) +#endif + #define SIGAR_ZERO(s) \ memset(s, '\0', sizeof(*(s))) diff --git a/src/os/linux/linux_sigar.c b/src/os/linux/linux_sigar.c index 1d431792..7f3ff415 100644 --- a/src/os/linux/linux_sigar.c +++ b/src/os/linux/linux_sigar.c @@ -1021,7 +1021,7 @@ static char *get_fsdev(sigar_t *sigar, ptr = fsp->dev_name; if (strnEQ(ptr, "/dev/", 5)) { ptr += 5; - ent->value = strdup(ptr); + ent->value = sigar_strdup(ptr); continue; } diff --git a/src/sigar.c b/src/sigar.c index 04c74b40..0a91e88c 100644 --- a/src/sigar.c +++ b/src/sigar.c @@ -1347,7 +1347,8 @@ int sigar_net_interface_list_get(sigar_t *sigar, } # endif #endif - iflist->data[iflist->number++] = strdup(ifr->ifr_name); + iflist->data[iflist->number++] = + sigar_strdup(ifr->ifr_name); } return SIGAR_OK;