mirror of https://github.com/xzeldon/htop.git
Hold only a const version of Settings in Process
This commit is contained in:
parent
7109172431
commit
4eb443926f
|
@ -399,7 +399,7 @@ const ProcessClass Process_class = {
|
||||||
.writeField = Process_writeField,
|
.writeField = Process_writeField,
|
||||||
};
|
};
|
||||||
|
|
||||||
void Process_init(Process* this, struct Settings_* settings) {
|
void Process_init(Process* this, const struct Settings_* settings) {
|
||||||
this->settings = settings;
|
this->settings = settings;
|
||||||
this->tag = false;
|
this->tag = false;
|
||||||
this->showChildren = true;
|
this->showChildren = true;
|
||||||
|
|
|
@ -59,7 +59,7 @@ struct Settings_;
|
||||||
typedef struct Process_ {
|
typedef struct Process_ {
|
||||||
Object super;
|
Object super;
|
||||||
|
|
||||||
struct Settings_* settings;
|
const struct Settings_* settings;
|
||||||
|
|
||||||
unsigned long long int time;
|
unsigned long long int time;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
@ -119,7 +119,7 @@ extern ProcessFieldData Process_fields[];
|
||||||
extern ProcessPidColumn Process_pidColumns[];
|
extern ProcessPidColumn Process_pidColumns[];
|
||||||
extern char Process_pidFormat[20];
|
extern char Process_pidFormat[20];
|
||||||
|
|
||||||
typedef Process*(*Process_New)(struct Settings_*);
|
typedef Process*(*Process_New)(const struct Settings_*);
|
||||||
typedef void (*Process_WriteField)(const Process*, RichString*, ProcessField);
|
typedef void (*Process_WriteField)(const Process*, RichString*, ProcessField);
|
||||||
|
|
||||||
typedef struct ProcessClass_ {
|
typedef struct ProcessClass_ {
|
||||||
|
@ -164,7 +164,7 @@ void Process_done(Process* this);
|
||||||
|
|
||||||
extern const ProcessClass Process_class;
|
extern const ProcessClass Process_class;
|
||||||
|
|
||||||
void Process_init(Process* this, struct Settings_* settings);
|
void Process_init(Process* this, const struct Settings_* settings);
|
||||||
|
|
||||||
void Process_toggleTag(Process* this);
|
void Process_toggleTag(Process* this);
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ const ProcessClass DarwinProcess_class = {
|
||||||
.writeField = Process_writeField,
|
.writeField = Process_writeField,
|
||||||
};
|
};
|
||||||
|
|
||||||
DarwinProcess* DarwinProcess_new(Settings* settings) {
|
Process* DarwinProcess_new(const Settings* settings) {
|
||||||
DarwinProcess* this = xCalloc(1, sizeof(DarwinProcess));
|
DarwinProcess* this = xCalloc(1, sizeof(DarwinProcess));
|
||||||
Object_setClass(this, Class(DarwinProcess));
|
Object_setClass(this, Class(DarwinProcess));
|
||||||
Process_init(&this->super, settings);
|
Process_init(&this->super, settings);
|
||||||
|
@ -37,7 +37,7 @@ DarwinProcess* DarwinProcess_new(Settings* settings) {
|
||||||
this->stime = 0;
|
this->stime = 0;
|
||||||
this->taskAccess = true;
|
this->taskAccess = true;
|
||||||
|
|
||||||
return this;
|
return &this->super;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Process_delete(Object* cast) {
|
void Process_delete(Object* cast) {
|
||||||
|
|
|
@ -22,7 +22,7 @@ typedef struct DarwinProcess_ {
|
||||||
|
|
||||||
extern const ProcessClass DarwinProcess_class;
|
extern const ProcessClass DarwinProcess_class;
|
||||||
|
|
||||||
DarwinProcess* DarwinProcess_new(Settings* settings);
|
Process* DarwinProcess_new(const Settings* settings);
|
||||||
|
|
||||||
void Process_delete(Object* cast);
|
void Process_delete(Object* cast);
|
||||||
|
|
||||||
|
|
|
@ -186,7 +186,7 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
|
||||||
ps = ProcessList_getKInfoProcs(&count);
|
ps = ProcessList_getKInfoProcs(&count);
|
||||||
|
|
||||||
for(size_t i = 0; i < count; ++i) {
|
for(size_t i = 0; i < count; ++i) {
|
||||||
proc = (DarwinProcess *)ProcessList_getProcess(super, ps[i].kp_proc.p_pid, &preExisting, (Process_New)DarwinProcess_new);
|
proc = (DarwinProcess *)ProcessList_getProcess(super, ps[i].kp_proc.p_pid, &preExisting, DarwinProcess_new);
|
||||||
|
|
||||||
DarwinProcess_setFromKInfoProc(&proc->super, &ps[i], preExisting);
|
DarwinProcess_setFromKInfoProc(&proc->super, &ps[i], preExisting);
|
||||||
DarwinProcess_setFromLibprocPidinfo(proc, dpl);
|
DarwinProcess_setFromLibprocPidinfo(proc, dpl);
|
||||||
|
|
|
@ -69,11 +69,11 @@ ProcessPidColumn Process_pidColumns[] = {
|
||||||
{ .id = 0, .label = NULL },
|
{ .id = 0, .label = NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
DragonFlyBSDProcess* DragonFlyBSDProcess_new(Settings* settings) {
|
Process* DragonFlyBSDProcess_new(const Settings* settings) {
|
||||||
DragonFlyBSDProcess* this = xCalloc(1, sizeof(DragonFlyBSDProcess));
|
DragonFlyBSDProcess* this = xCalloc(1, sizeof(DragonFlyBSDProcess));
|
||||||
Object_setClass(this, Class(DragonFlyBSDProcess));
|
Object_setClass(this, Class(DragonFlyBSDProcess));
|
||||||
Process_init(&this->super, settings);
|
Process_init(&this->super, settings);
|
||||||
return this;
|
return &this->super;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Process_delete(Object* cast) {
|
void Process_delete(Object* cast) {
|
||||||
|
|
|
@ -33,7 +33,7 @@ extern ProcessFieldData Process_fields[];
|
||||||
|
|
||||||
extern ProcessPidColumn Process_pidColumns[];
|
extern ProcessPidColumn Process_pidColumns[];
|
||||||
|
|
||||||
DragonFlyBSDProcess* DragonFlyBSDProcess_new(Settings* settings);
|
Process* DragonFlyBSDProcess_new(const Settings* settings);
|
||||||
|
|
||||||
void Process_delete(Object* cast);
|
void Process_delete(Object* cast);
|
||||||
|
|
||||||
|
|
|
@ -385,7 +385,7 @@ void ProcessList_goThroughEntries(ProcessList* this, bool pauseProcessUpdate) {
|
||||||
bool ATTR_UNUSED isIdleProcess = false;
|
bool ATTR_UNUSED isIdleProcess = false;
|
||||||
|
|
||||||
// note: dragonflybsd kernel processes all have the same pid, so we misuse the kernel thread address to give them a unique identifier
|
// note: dragonflybsd kernel processes all have the same pid, so we misuse the kernel thread address to give them a unique identifier
|
||||||
Process* proc = ProcessList_getProcess(this, kproc->kp_ktaddr ? (pid_t)kproc->kp_ktaddr : kproc->kp_pid, &preExisting, (Process_New) DragonFlyBSDProcess_new);
|
Process* proc = ProcessList_getProcess(this, kproc->kp_ktaddr ? (pid_t)kproc->kp_ktaddr : kproc->kp_pid, &preExisting, DragonFlyBSDProcess_new);
|
||||||
DragonFlyBSDProcess* dfp = (DragonFlyBSDProcess*) proc;
|
DragonFlyBSDProcess* dfp = (DragonFlyBSDProcess*) proc;
|
||||||
|
|
||||||
proc->show = ! ((hideKernelThreads && Process_isKernelThread(dfp)) || (hideUserlandThreads && Process_isUserlandThread(proc)));
|
proc->show = ! ((hideKernelThreads && Process_isKernelThread(dfp)) || (hideUserlandThreads && Process_isUserlandThread(proc)));
|
||||||
|
|
|
@ -69,11 +69,11 @@ ProcessPidColumn Process_pidColumns[] = {
|
||||||
{ .id = 0, .label = NULL },
|
{ .id = 0, .label = NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
FreeBSDProcess* FreeBSDProcess_new(Settings* settings) {
|
Process* FreeBSDProcess_new(const Settings* settings) {
|
||||||
FreeBSDProcess* this = xCalloc(1, sizeof(FreeBSDProcess));
|
FreeBSDProcess* this = xCalloc(1, sizeof(FreeBSDProcess));
|
||||||
Object_setClass(this, Class(FreeBSDProcess));
|
Object_setClass(this, Class(FreeBSDProcess));
|
||||||
Process_init(&this->super, settings);
|
Process_init(&this->super, settings);
|
||||||
return this;
|
return &this->super;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Process_delete(Object* cast) {
|
void Process_delete(Object* cast) {
|
||||||
|
|
|
@ -39,7 +39,7 @@ extern ProcessFieldData Process_fields[];
|
||||||
|
|
||||||
extern ProcessPidColumn Process_pidColumns[];
|
extern ProcessPidColumn Process_pidColumns[];
|
||||||
|
|
||||||
FreeBSDProcess* FreeBSDProcess_new(Settings* settings);
|
Process* FreeBSDProcess_new(const Settings* settings);
|
||||||
|
|
||||||
void Process_delete(Object* cast);
|
void Process_delete(Object* cast);
|
||||||
|
|
||||||
|
|
|
@ -401,7 +401,7 @@ void ProcessList_goThroughEntries(ProcessList* this, bool pauseProcessUpdate) {
|
||||||
struct kinfo_proc* kproc = &kprocs[i];
|
struct kinfo_proc* kproc = &kprocs[i];
|
||||||
bool preExisting = false;
|
bool preExisting = false;
|
||||||
// TODO: bool isIdleProcess = false;
|
// TODO: bool isIdleProcess = false;
|
||||||
Process* proc = ProcessList_getProcess(this, kproc->ki_pid, &preExisting, (Process_New) FreeBSDProcess_new);
|
Process* proc = ProcessList_getProcess(this, kproc->ki_pid, &preExisting, FreeBSDProcess_new);
|
||||||
FreeBSDProcess* fp = (FreeBSDProcess*) proc;
|
FreeBSDProcess* fp = (FreeBSDProcess*) proc;
|
||||||
|
|
||||||
proc->show = ! ((hideKernelThreads && Process_isKernelThread(fp)) || (hideUserlandThreads && Process_isUserlandThread(proc)));
|
proc->show = ! ((hideKernelThreads && Process_isKernelThread(fp)) || (hideUserlandThreads && Process_isUserlandThread(proc)));
|
||||||
|
|
|
@ -138,11 +138,11 @@ const ProcessClass LinuxProcess_class = {
|
||||||
.writeField = LinuxProcess_writeField,
|
.writeField = LinuxProcess_writeField,
|
||||||
};
|
};
|
||||||
|
|
||||||
LinuxProcess* LinuxProcess_new(Settings* settings) {
|
Process* LinuxProcess_new(const Settings* settings) {
|
||||||
LinuxProcess* this = xCalloc(1, sizeof(LinuxProcess));
|
LinuxProcess* this = xCalloc(1, sizeof(LinuxProcess));
|
||||||
Object_setClass(this, Class(LinuxProcess));
|
Object_setClass(this, Class(LinuxProcess));
|
||||||
Process_init(&this->super, settings);
|
Process_init(&this->super, settings);
|
||||||
return this;
|
return &this->super;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Process_delete(Object* cast) {
|
void Process_delete(Object* cast) {
|
||||||
|
|
|
@ -167,7 +167,7 @@ extern ProcessPidColumn Process_pidColumns[];
|
||||||
|
|
||||||
extern const ProcessClass LinuxProcess_class;
|
extern const ProcessClass LinuxProcess_class;
|
||||||
|
|
||||||
LinuxProcess* LinuxProcess_new(Settings* settings);
|
Process* LinuxProcess_new(const Settings* settings);
|
||||||
|
|
||||||
void Process_delete(Object* cast);
|
void Process_delete(Object* cast);
|
||||||
|
|
||||||
|
|
|
@ -971,7 +971,7 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, const char*
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
bool preExisting = false;
|
bool preExisting = false;
|
||||||
Process* proc = ProcessList_getProcess(pl, pid, &preExisting, (Process_New) LinuxProcess_new);
|
Process* proc = ProcessList_getProcess(pl, pid, &preExisting, LinuxProcess_new);
|
||||||
proc->tgid = parent ? parent->pid : pid;
|
proc->tgid = parent ? parent->pid : pid;
|
||||||
|
|
||||||
LinuxProcess* lp = (LinuxProcess*) proc;
|
LinuxProcess* lp = (LinuxProcess*) proc;
|
||||||
|
|
|
@ -165,11 +165,11 @@ ProcessPidColumn Process_pidColumns[] = {
|
||||||
{ .id = 0, .label = NULL },
|
{ .id = 0, .label = NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
OpenBSDProcess* OpenBSDProcess_new(Settings* settings) {
|
Process* OpenBSDProcess_new(const Settings* settings) {
|
||||||
OpenBSDProcess* this = xCalloc(sizeof(OpenBSDProcess), 1);
|
OpenBSDProcess* this = xCalloc(sizeof(OpenBSDProcess), 1);
|
||||||
Object_setClass(this, Class(OpenBSDProcess));
|
Object_setClass(this, Class(OpenBSDProcess));
|
||||||
Process_init(&this->super, settings);
|
Process_init(&this->super, settings);
|
||||||
return this;
|
return &this->this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Process_delete(Object* cast) {
|
void Process_delete(Object* cast) {
|
||||||
|
|
|
@ -27,7 +27,7 @@ extern ProcessFieldData Process_fields[];
|
||||||
|
|
||||||
extern ProcessPidColumn Process_pidColumns[];
|
extern ProcessPidColumn Process_pidColumns[];
|
||||||
|
|
||||||
OpenBSDProcess* OpenBSDProcess_new(Settings* settings);
|
Process* OpenBSDProcess_new(const Settings* settings);
|
||||||
|
|
||||||
void Process_delete(Object* cast);
|
void Process_delete(Object* cast);
|
||||||
|
|
||||||
|
|
|
@ -203,7 +203,7 @@ static inline void OpenBSDProcessList_scanProcs(OpenBSDProcessList* this) {
|
||||||
kproc = &kprocs[i];
|
kproc = &kprocs[i];
|
||||||
|
|
||||||
preExisting = false;
|
preExisting = false;
|
||||||
proc = ProcessList_getProcess(&this->super, kproc->p_pid, &preExisting, (Process_New) OpenBSDProcess_new);
|
proc = ProcessList_getProcess(&this->super, kproc->p_pid, &preExisting, OpenBSDProcess_new);
|
||||||
fp = (OpenBSDProcess*) proc;
|
fp = (OpenBSDProcess*) proc;
|
||||||
|
|
||||||
proc->show = ! ((hideKernelThreads && Process_isKernelThread(proc))
|
proc->show = ! ((hideKernelThreads && Process_isKernelThread(proc))
|
||||||
|
|
|
@ -79,11 +79,11 @@ ProcessPidColumn Process_pidColumns[] = {
|
||||||
{ .id = 0, .label = NULL },
|
{ .id = 0, .label = NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
SolarisProcess* SolarisProcess_new(Settings* settings) {
|
Process* SolarisProcess_new(const Settings* settings) {
|
||||||
SolarisProcess* this = xCalloc(1, sizeof(SolarisProcess));
|
SolarisProcess* this = xCalloc(1, sizeof(SolarisProcess));
|
||||||
Object_setClass(this, Class(SolarisProcess));
|
Object_setClass(this, Class(SolarisProcess));
|
||||||
Process_init(&this->super, settings);
|
Process_init(&this->super, settings);
|
||||||
return this;
|
return &this->super;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Process_delete(Object* cast) {
|
void Process_delete(Object* cast) {
|
||||||
|
|
|
@ -50,7 +50,7 @@ extern ProcessFieldData Process_fields[];
|
||||||
|
|
||||||
extern ProcessPidColumn Process_pidColumns[];
|
extern ProcessPidColumn Process_pidColumns[];
|
||||||
|
|
||||||
SolarisProcess* SolarisProcess_new(Settings* settings);
|
Process* SolarisProcess_new(const Settings* settings);
|
||||||
|
|
||||||
void Process_delete(Object* cast);
|
void Process_delete(Object* cast);
|
||||||
|
|
||||||
|
|
|
@ -279,7 +279,7 @@ int SolarisProcessList_walkproc(psinfo_t *_psinfo, lwpsinfo_t *_lwpsinfo, void *
|
||||||
} else {
|
} else {
|
||||||
getpid = lwpid;
|
getpid = lwpid;
|
||||||
}
|
}
|
||||||
Process *proc = ProcessList_getProcess(pl, getpid, &preExisting, (Process_New) SolarisProcess_new);
|
Process *proc = ProcessList_getProcess(pl, getpid, &preExisting, SolarisProcess_new);
|
||||||
SolarisProcess *sproc = (SolarisProcess*) proc;
|
SolarisProcess *sproc = (SolarisProcess*) proc;
|
||||||
|
|
||||||
// Common code pass 1
|
// Common code pass 1
|
||||||
|
|
Loading…
Reference in New Issue