Rename cmdlineBasenameOffset to cmdlineBasenameEnd to properly indicate the fields purpose

This commit is contained in:
Benny Baumann
2021-04-10 11:46:57 +02:00
committed by BenBE
parent 666f70c58c
commit 94a52cb5c9
10 changed files with 41 additions and 41 deletions

View File

@ -101,7 +101,7 @@ bool Process_isThread(const Process* this) {
return false;
}
static char* DarwinProcess_getCmdLine(const struct kinfo_proc* k, int* cmdlineBasenameOffset) {
static char* DarwinProcess_getCmdLine(const struct kinfo_proc* k, int* cmdlineBasenameEnd) {
/* This function is from the old Mac version of htop. Originally from ps? */
int mib[3], argmax, nargs, c = 0;
size_t size;
@ -199,7 +199,7 @@ static char* DarwinProcess_getCmdLine(const struct kinfo_proc* k, int* cmdlineBa
/* Save where the argv[0] string starts. */
sp = cp;
*cmdlineBasenameOffset = 0;
*cmdlineBasenameEnd = 0;
for ( np = NULL; c < nargs && cp < &procargs[size]; cp++ ) {
if ( *cp == '\0' ) {
c++;
@ -209,8 +209,8 @@ static char* DarwinProcess_getCmdLine(const struct kinfo_proc* k, int* cmdlineBa
}
/* Note location of current '\0'. */
np = cp;
if (*cmdlineBasenameOffset == 0) {
*cmdlineBasenameOffset = cp - sp;
if (*cmdlineBasenameEnd == 0) {
*cmdlineBasenameEnd = cp - sp;
}
}
}
@ -223,8 +223,8 @@ static char* DarwinProcess_getCmdLine(const struct kinfo_proc* k, int* cmdlineBa
/* Empty or unterminated string. */
goto ERROR_B;
}
if (*cmdlineBasenameOffset == 0) {
*cmdlineBasenameOffset = np - sp;
if (*cmdlineBasenameEnd == 0) {
*cmdlineBasenameEnd = np - sp;
}
/* Make a copy of the string. */
@ -239,7 +239,7 @@ ERROR_B:
free( procargs );
ERROR_A:
*cmdlineBasenameOffset = -1;
*cmdlineBasenameEnd = -1;
retval = xStrdup(k->kp_proc.p_comm);
return retval;
@ -287,7 +287,7 @@ void DarwinProcess_setFromKInfoProc(Process* proc, const struct kinfo_proc* ps,
proc->starttime_ctime = ep->p_starttime.tv_sec;
Process_fillStarttimeBuffer(proc);
proc->cmdline = DarwinProcess_getCmdLine(ps, &proc->cmdlineBasenameOffset);
proc->cmdline = DarwinProcess_getCmdLine(ps, &proc->cmdlineBasenameEnd);
}
/* Mutable information */