mirror of https://github.com/xzeldon/htop.git
Simplify environment-reading code
Suggested PR changes, thanks @cgzones
This commit is contained in:
parent
0ae2bb1f8e
commit
94e32cf1e8
|
@ -221,16 +221,10 @@ void Platform_setZfsCompressedArcValues(Meter* this) {
|
||||||
}
|
}
|
||||||
|
|
||||||
char* Platform_getProcessEnv(pid_t pid) {
|
char* Platform_getProcessEnv(pid_t pid) {
|
||||||
int mib[4];
|
int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_ENV, pid };
|
||||||
char *env = NULL;
|
|
||||||
|
|
||||||
mib[0] = CTL_KERN;
|
|
||||||
mib[1] = KERN_PROC;
|
|
||||||
mib[2] = KERN_PROC_ENV;
|
|
||||||
mib[3] = pid;
|
|
||||||
|
|
||||||
size_t capacity = ARG_MAX;
|
size_t capacity = ARG_MAX;
|
||||||
env = xMalloc(capacity);
|
char* env = xMalloc(capacity);
|
||||||
|
|
||||||
int err = sysctl(mib, 4, env, &capacity, NULL, 0);
|
int err = sysctl(mib, 4, env, &capacity, NULL, 0);
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
Loading…
Reference in New Issue