diff --git a/Process.c b/Process.c index 5f5be13a..842232f7 100644 --- a/Process.c +++ b/Process.c @@ -399,7 +399,7 @@ const ProcessClass Process_class = { .writeField = Process_writeField, }; -void Process_init(Process* this, struct Settings_* settings) { +void Process_init(Process* this, const struct Settings_* settings) { this->settings = settings; this->tag = false; this->showChildren = true; diff --git a/Process.h b/Process.h index 440cbb1c..2432918f 100644 --- a/Process.h +++ b/Process.h @@ -59,7 +59,7 @@ struct Settings_; typedef struct Process_ { Object super; - struct Settings_* settings; + const struct Settings_* settings; unsigned long long int time; pid_t pid; @@ -119,7 +119,7 @@ extern ProcessFieldData Process_fields[]; extern ProcessPidColumn Process_pidColumns[]; 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 struct ProcessClass_ { @@ -164,7 +164,7 @@ void Process_done(Process* this); 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); diff --git a/darwin/DarwinProcess.c b/darwin/DarwinProcess.c index 7049cb1e..73214836 100644 --- a/darwin/DarwinProcess.c +++ b/darwin/DarwinProcess.c @@ -28,7 +28,7 @@ const ProcessClass DarwinProcess_class = { .writeField = Process_writeField, }; -DarwinProcess* DarwinProcess_new(Settings* settings) { +Process* DarwinProcess_new(const Settings* settings) { DarwinProcess* this = xCalloc(1, sizeof(DarwinProcess)); Object_setClass(this, Class(DarwinProcess)); Process_init(&this->super, settings); @@ -37,7 +37,7 @@ DarwinProcess* DarwinProcess_new(Settings* settings) { this->stime = 0; this->taskAccess = true; - return this; + return &this->super; } void Process_delete(Object* cast) { diff --git a/darwin/DarwinProcess.h b/darwin/DarwinProcess.h index 69a1d63b..1d9dc34a 100644 --- a/darwin/DarwinProcess.h +++ b/darwin/DarwinProcess.h @@ -22,7 +22,7 @@ typedef struct DarwinProcess_ { extern const ProcessClass DarwinProcess_class; -DarwinProcess* DarwinProcess_new(Settings* settings); +Process* DarwinProcess_new(const Settings* settings); void Process_delete(Object* cast); diff --git a/darwin/DarwinProcessList.c b/darwin/DarwinProcessList.c index 2c9f533f..bae8e222 100644 --- a/darwin/DarwinProcessList.c +++ b/darwin/DarwinProcessList.c @@ -186,7 +186,7 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) { ps = ProcessList_getKInfoProcs(&count); 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_setFromLibprocPidinfo(proc, dpl); diff --git a/dragonflybsd/DragonFlyBSDProcess.c b/dragonflybsd/DragonFlyBSDProcess.c index 517fc2a1..6650cb7e 100644 --- a/dragonflybsd/DragonFlyBSDProcess.c +++ b/dragonflybsd/DragonFlyBSDProcess.c @@ -69,11 +69,11 @@ ProcessPidColumn Process_pidColumns[] = { { .id = 0, .label = NULL }, }; -DragonFlyBSDProcess* DragonFlyBSDProcess_new(Settings* settings) { +Process* DragonFlyBSDProcess_new(const Settings* settings) { DragonFlyBSDProcess* this = xCalloc(1, sizeof(DragonFlyBSDProcess)); Object_setClass(this, Class(DragonFlyBSDProcess)); Process_init(&this->super, settings); - return this; + return &this->super; } void Process_delete(Object* cast) { diff --git a/dragonflybsd/DragonFlyBSDProcess.h b/dragonflybsd/DragonFlyBSDProcess.h index 92e1dde2..1befd946 100644 --- a/dragonflybsd/DragonFlyBSDProcess.h +++ b/dragonflybsd/DragonFlyBSDProcess.h @@ -33,7 +33,7 @@ extern ProcessFieldData Process_fields[]; extern ProcessPidColumn Process_pidColumns[]; -DragonFlyBSDProcess* DragonFlyBSDProcess_new(Settings* settings); +Process* DragonFlyBSDProcess_new(const Settings* settings); void Process_delete(Object* cast); diff --git a/dragonflybsd/DragonFlyBSDProcessList.c b/dragonflybsd/DragonFlyBSDProcessList.c index 73ef025a..7fcee410 100644 --- a/dragonflybsd/DragonFlyBSDProcessList.c +++ b/dragonflybsd/DragonFlyBSDProcessList.c @@ -385,7 +385,7 @@ void ProcessList_goThroughEntries(ProcessList* this, bool pauseProcessUpdate) { 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 - 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; proc->show = ! ((hideKernelThreads && Process_isKernelThread(dfp)) || (hideUserlandThreads && Process_isUserlandThread(proc))); diff --git a/freebsd/FreeBSDProcess.c b/freebsd/FreeBSDProcess.c index 684f4dfe..ea3f693d 100644 --- a/freebsd/FreeBSDProcess.c +++ b/freebsd/FreeBSDProcess.c @@ -69,11 +69,11 @@ ProcessPidColumn Process_pidColumns[] = { { .id = 0, .label = NULL }, }; -FreeBSDProcess* FreeBSDProcess_new(Settings* settings) { +Process* FreeBSDProcess_new(const Settings* settings) { FreeBSDProcess* this = xCalloc(1, sizeof(FreeBSDProcess)); Object_setClass(this, Class(FreeBSDProcess)); Process_init(&this->super, settings); - return this; + return &this->super; } void Process_delete(Object* cast) { diff --git a/freebsd/FreeBSDProcess.h b/freebsd/FreeBSDProcess.h index d7b40101..aa769d65 100644 --- a/freebsd/FreeBSDProcess.h +++ b/freebsd/FreeBSDProcess.h @@ -39,7 +39,7 @@ extern ProcessFieldData Process_fields[]; extern ProcessPidColumn Process_pidColumns[]; -FreeBSDProcess* FreeBSDProcess_new(Settings* settings); +Process* FreeBSDProcess_new(const Settings* settings); void Process_delete(Object* cast); diff --git a/freebsd/FreeBSDProcessList.c b/freebsd/FreeBSDProcessList.c index c8057060..4e418446 100644 --- a/freebsd/FreeBSDProcessList.c +++ b/freebsd/FreeBSDProcessList.c @@ -401,7 +401,7 @@ void ProcessList_goThroughEntries(ProcessList* this, bool pauseProcessUpdate) { struct kinfo_proc* kproc = &kprocs[i]; bool preExisting = 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; proc->show = ! ((hideKernelThreads && Process_isKernelThread(fp)) || (hideUserlandThreads && Process_isUserlandThread(proc))); diff --git a/linux/LinuxProcess.c b/linux/LinuxProcess.c index b53692d8..23783ef0 100644 --- a/linux/LinuxProcess.c +++ b/linux/LinuxProcess.c @@ -138,11 +138,11 @@ const ProcessClass LinuxProcess_class = { .writeField = LinuxProcess_writeField, }; -LinuxProcess* LinuxProcess_new(Settings* settings) { +Process* LinuxProcess_new(const Settings* settings) { LinuxProcess* this = xCalloc(1, sizeof(LinuxProcess)); Object_setClass(this, Class(LinuxProcess)); Process_init(&this->super, settings); - return this; + return &this->super; } void Process_delete(Object* cast) { diff --git a/linux/LinuxProcess.h b/linux/LinuxProcess.h index bb0c5ebb..45a3127f 100644 --- a/linux/LinuxProcess.h +++ b/linux/LinuxProcess.h @@ -167,7 +167,7 @@ extern ProcessPidColumn Process_pidColumns[]; extern const ProcessClass LinuxProcess_class; -LinuxProcess* LinuxProcess_new(Settings* settings); +Process* LinuxProcess_new(const Settings* settings); void Process_delete(Object* cast); diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c index 421d0c94..0903531a 100644 --- a/linux/LinuxProcessList.c +++ b/linux/LinuxProcessList.c @@ -971,7 +971,7 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, const char* continue; 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; LinuxProcess* lp = (LinuxProcess*) proc; diff --git a/openbsd/OpenBSDProcess.c b/openbsd/OpenBSDProcess.c index bc6ef4a8..c43fe2fc 100644 --- a/openbsd/OpenBSDProcess.c +++ b/openbsd/OpenBSDProcess.c @@ -165,11 +165,11 @@ ProcessPidColumn Process_pidColumns[] = { { .id = 0, .label = NULL }, }; -OpenBSDProcess* OpenBSDProcess_new(Settings* settings) { +Process* OpenBSDProcess_new(const Settings* settings) { OpenBSDProcess* this = xCalloc(sizeof(OpenBSDProcess), 1); Object_setClass(this, Class(OpenBSDProcess)); Process_init(&this->super, settings); - return this; + return &this->this; } void Process_delete(Object* cast) { diff --git a/openbsd/OpenBSDProcess.h b/openbsd/OpenBSDProcess.h index c9d4e381..12ce1840 100644 --- a/openbsd/OpenBSDProcess.h +++ b/openbsd/OpenBSDProcess.h @@ -27,7 +27,7 @@ extern ProcessFieldData Process_fields[]; extern ProcessPidColumn Process_pidColumns[]; -OpenBSDProcess* OpenBSDProcess_new(Settings* settings); +Process* OpenBSDProcess_new(const Settings* settings); void Process_delete(Object* cast); diff --git a/openbsd/OpenBSDProcessList.c b/openbsd/OpenBSDProcessList.c index 5838fea9..693ec9db 100644 --- a/openbsd/OpenBSDProcessList.c +++ b/openbsd/OpenBSDProcessList.c @@ -203,7 +203,7 @@ static inline void OpenBSDProcessList_scanProcs(OpenBSDProcessList* this) { kproc = &kprocs[i]; 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; proc->show = ! ((hideKernelThreads && Process_isKernelThread(proc)) diff --git a/solaris/SolarisProcess.c b/solaris/SolarisProcess.c index 13652bd3..9c6c7d77 100644 --- a/solaris/SolarisProcess.c +++ b/solaris/SolarisProcess.c @@ -79,11 +79,11 @@ ProcessPidColumn Process_pidColumns[] = { { .id = 0, .label = NULL }, }; -SolarisProcess* SolarisProcess_new(Settings* settings) { +Process* SolarisProcess_new(const Settings* settings) { SolarisProcess* this = xCalloc(1, sizeof(SolarisProcess)); Object_setClass(this, Class(SolarisProcess)); Process_init(&this->super, settings); - return this; + return &this->super; } void Process_delete(Object* cast) { diff --git a/solaris/SolarisProcess.h b/solaris/SolarisProcess.h index 23012a2f..4756634d 100644 --- a/solaris/SolarisProcess.h +++ b/solaris/SolarisProcess.h @@ -50,7 +50,7 @@ extern ProcessFieldData Process_fields[]; extern ProcessPidColumn Process_pidColumns[]; -SolarisProcess* SolarisProcess_new(Settings* settings); +Process* SolarisProcess_new(const Settings* settings); void Process_delete(Object* cast); diff --git a/solaris/SolarisProcessList.c b/solaris/SolarisProcessList.c index 85fc955b..72806134 100644 --- a/solaris/SolarisProcessList.c +++ b/solaris/SolarisProcessList.c @@ -279,7 +279,7 @@ int SolarisProcessList_walkproc(psinfo_t *_psinfo, lwpsinfo_t *_lwpsinfo, void * } else { 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; // Common code pass 1