ProcessList* ProcessList_new(UsersTable* usersTable) { ProcessList* this; this = calloc(sizeof(ProcessList), 1); this->processes = Vector_new(PROCESS_CLASS, true, DEFAULT_SIZE, Process_compare); this->processTable = Hashtable_new(70, false); assert(Hashtable_count(this->processTable) == Vector_count(this->processes)); this->usersTable = usersTable; /* tree-view auxiliary buffers */ this->processes2 = Vector_new(PROCESS_CLASS, true, DEFAULT_SIZE, Process_compare); FILE* file = fopen(PROCSTATFILE, "r"); assert(file != NULL); char buffer[256]; int cpus = -1; do { cpus++; fgets(buffer, 255, file); } while (String_startsWith(buffer, "cpu")); fclose(file); this->cpuCount = cpus - 1; this->cpus = calloc(sizeof(CPUData), cpus); for (int i = 0; i < cpus; i++) { this->cpus[i].totalTime = 1; this->cpus[i].totalPeriod = 1; } this->fields = calloc(sizeof(ProcessField), LAST_PROCESSFIELD+1); // TODO: turn 'fields' into a Vector, // (and ProcessFields into proper objects). for (int i = 0; defaultHeaders[i]; i++) { this->fields[i] = defaultHeaders[i]; } this->sortKey = PERCENT_CPU; this->direction = 1; this->hideThreads = false; this->shadowOtherUsers = false; this->showThreadNames = false; this->showingThreadNames = false; this->hideKernelThreads = false; this->hideUserlandThreads = false; this->treeView = false; this->highlightBaseName = false; this->highlightMegabytes = false; this->detailedCPUTime = false; this->countCPUsFromZero = false; return this; }
bool AntiDOS_isOversized(AntiDOS *dos) { return Vector_count(&dos->data) >= ANTIDOS_ENTRIES_MAX; }