mirror of
https://github.com/xzeldon/htop.git
synced 2025-07-15 05:24:36 +03:00
Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
0384613450 |
16
ChangeLog
16
ChangeLog
@ -1,20 +1,4 @@
|
||||
|
||||
What's new in version 0.6.5
|
||||
|
||||
* Add hardened-debug flags for debugging with Hardened GCC
|
||||
* BUGFIX: Handle error condition when a directory vanishes
|
||||
from /proc
|
||||
* BUGFIX: Fix leak of process command line
|
||||
* BUGFIX: Collect orphaned items when arranging the tree view.
|
||||
(thanks to Wolfram Schlich for assistance with debugging)
|
||||
* Separate proc and memory debugging into separate #defines.
|
||||
* BUGFIX: Fix message when configure fails due to
|
||||
missing libraries
|
||||
(thanks to Jon)
|
||||
* BUGFIX: Don't truncate value when displaying a very large
|
||||
process
|
||||
(thanks to Bo Liu)
|
||||
|
||||
What's new in version 0.6.4
|
||||
|
||||
* Add an option to split the display of kernel time
|
||||
|
@ -49,11 +49,7 @@ void DebugMemory_new() {
|
||||
singleton->allocations = 0;
|
||||
singleton->deallocations = 0;
|
||||
singleton->size = 0;
|
||||
#ifdef DEBUG_ALLOC
|
||||
singleton->file = fopen("/tmp/htop-debug-alloc.txt", "w");
|
||||
#else
|
||||
singleton->file = NULL;
|
||||
#endif
|
||||
singleton->totals = true;
|
||||
//singleton->file = NULL;
|
||||
}
|
||||
|
75
Hashtable.c
75
Hashtable.c
@ -9,7 +9,6 @@ in the source distribution for its full text.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
@ -32,35 +31,6 @@ struct Hashtable_ {
|
||||
};
|
||||
}*/
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
bool Hashtable_isConsistent(Hashtable* this) {
|
||||
int items = 0;
|
||||
for (int i = 0; i < this->size; i++) {
|
||||
HashtableItem* bucket = this->buckets[i];
|
||||
while (bucket) {
|
||||
items++;
|
||||
bucket = bucket->next;
|
||||
}
|
||||
}
|
||||
return items == this->items;
|
||||
}
|
||||
|
||||
int Hashtable_count(Hashtable* this) {
|
||||
int items = 0;
|
||||
for (int i = 0; i < this->size; i++) {
|
||||
HashtableItem* bucket = this->buckets[i];
|
||||
while (bucket) {
|
||||
items++;
|
||||
bucket = bucket->next;
|
||||
}
|
||||
}
|
||||
assert(items == this->items);
|
||||
return items;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
HashtableItem* HashtableItem_new(int key, void* value) {
|
||||
HashtableItem* this;
|
||||
|
||||
@ -75,16 +45,13 @@ Hashtable* Hashtable_new(int size, bool owner) {
|
||||
Hashtable* this;
|
||||
|
||||
this = (Hashtable*) malloc(sizeof(Hashtable));
|
||||
this->items = 0;
|
||||
this->size = size;
|
||||
this->buckets = (HashtableItem**) calloc(sizeof(HashtableItem*), size);
|
||||
this->owner = owner;
|
||||
assert(Hashtable_isConsistent(this));
|
||||
return this;
|
||||
}
|
||||
|
||||
void Hashtable_delete(Hashtable* this) {
|
||||
assert(Hashtable_isConsistent(this));
|
||||
for (int i = 0; i < this->size; i++) {
|
||||
HashtableItem* walk = this->buckets[i];
|
||||
while (walk != NULL) {
|
||||
@ -100,7 +67,6 @@ void Hashtable_delete(Hashtable* this) {
|
||||
}
|
||||
|
||||
inline int Hashtable_size(Hashtable* this) {
|
||||
assert(Hashtable_isConsistent(this));
|
||||
return this->items;
|
||||
}
|
||||
|
||||
@ -119,53 +85,47 @@ void Hashtable_put(Hashtable* this, int key, void* value) {
|
||||
break;
|
||||
} else
|
||||
bucketPtr = &((*bucketPtr)->next);
|
||||
assert(Hashtable_isConsistent(this));
|
||||
}
|
||||
|
||||
void* Hashtable_remove(Hashtable* this, int key) {
|
||||
int index = key % this->size;
|
||||
|
||||
assert(Hashtable_isConsistent(this));
|
||||
|
||||
HashtableItem** bucket;
|
||||
for (bucket = &(this->buckets[index]); *bucket; bucket = &((*bucket)->next) ) {
|
||||
if ((*bucket)->key == key) {
|
||||
void* value = (*bucket)->value;
|
||||
HashtableItem* next = (*bucket)->next;
|
||||
free(*bucket);
|
||||
(*bucket) = next;
|
||||
HashtableItem** bucketPtr = &(this->buckets[index]);
|
||||
while (true)
|
||||
if (*bucketPtr == NULL) {
|
||||
return NULL;
|
||||
break;
|
||||
} else if ((*bucketPtr)->key == key) {
|
||||
void* savedValue = (*bucketPtr)->value;
|
||||
HashtableItem* savedNext = (*bucketPtr)->next;
|
||||
free(*bucketPtr);
|
||||
(*bucketPtr) = savedNext;
|
||||
this->items--;
|
||||
if (this->owner) {
|
||||
free(value);
|
||||
assert(Hashtable_isConsistent(this));
|
||||
free(savedValue);
|
||||
return NULL;
|
||||
} else {
|
||||
assert(Hashtable_isConsistent(this));
|
||||
return value;
|
||||
return savedValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
assert(Hashtable_isConsistent(this));
|
||||
return NULL;
|
||||
} else
|
||||
bucketPtr = &((*bucketPtr)->next);
|
||||
}
|
||||
|
||||
//#include <stdio.h>
|
||||
inline void* Hashtable_get(Hashtable* this, int key) {
|
||||
int index = key % this->size;
|
||||
HashtableItem* bucketPtr = this->buckets[index];
|
||||
// fprintf(stderr, "%d -> %d\n", key, index);
|
||||
while (true) {
|
||||
if (bucketPtr == NULL) {
|
||||
assert(Hashtable_isConsistent(this));
|
||||
return NULL;
|
||||
} else if (bucketPtr->key == key) {
|
||||
assert(Hashtable_isConsistent(this));
|
||||
return bucketPtr->value;
|
||||
} else
|
||||
bucketPtr = bucketPtr->next;
|
||||
// fprintf(stderr, "*\n");
|
||||
}
|
||||
}
|
||||
|
||||
void Hashtable_foreach(Hashtable* this, Hashtable_PairFunction f, void* userData) {
|
||||
assert(Hashtable_isConsistent(this));
|
||||
for (int i = 0; i < this->size; i++) {
|
||||
HashtableItem* walk = this->buckets[i];
|
||||
while (walk != NULL) {
|
||||
@ -173,5 +133,4 @@ void Hashtable_foreach(Hashtable* this, Hashtable_PairFunction f, void* userData
|
||||
walk = walk->next;
|
||||
}
|
||||
}
|
||||
assert(Hashtable_isConsistent(this));
|
||||
}
|
||||
|
11
Hashtable.h
11
Hashtable.h
@ -12,7 +12,6 @@ in the source distribution for its full text.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
@ -33,14 +32,6 @@ struct Hashtable_ {
|
||||
bool owner;
|
||||
};
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
bool Hashtable_isConsistent(Hashtable* this);
|
||||
|
||||
int Hashtable_count(Hashtable* this);
|
||||
|
||||
#endif
|
||||
|
||||
HashtableItem* HashtableItem_new(int key, void* value);
|
||||
|
||||
Hashtable* Hashtable_new(int size, bool owner);
|
||||
@ -52,7 +43,7 @@ inline int Hashtable_size(Hashtable* this);
|
||||
void Hashtable_put(Hashtable* this, int key, void* value);
|
||||
|
||||
void* Hashtable_remove(Hashtable* this, int key);
|
||||
|
||||
//#include <stdio.h>
|
||||
inline void* Hashtable_get(Hashtable* this, int key);
|
||||
|
||||
void Hashtable_foreach(Hashtable* this, Hashtable_PairFunction f, void* userData);
|
||||
|
@ -32,11 +32,7 @@ profile:
|
||||
$(MAKE) all CFLAGS="-pg -O2"
|
||||
|
||||
debug:
|
||||
$(MAKE) all CFLAGS="-ggdb -DDEBUG"
|
||||
|
||||
hardened-debug:
|
||||
$(MAKE) all CFLAGS="-ggdb -DDEBUG" LDFLAGS="-nopie"
|
||||
$(MAKE) all CFLAGS="-g -DDEBUG"
|
||||
|
||||
debuglite:
|
||||
$(MAKE) all CFLAGS="-ggdb -DDEBUGLITE"
|
||||
|
||||
$(MAKE) all CFLAGS="-g -DDEBUGLITE"
|
||||
|
16
Process.c
16
Process.c
@ -126,14 +126,12 @@ Process* Process_new(struct ProcessList_ *pl) {
|
||||
Object_setClass(this, PROCESS_CLASS);
|
||||
((Object*)this)->display = Process_display;
|
||||
((Object*)this)->delete = Process_delete;
|
||||
this->pid = 0;
|
||||
this->pl = pl;
|
||||
this->tag = false;
|
||||
this->updated = false;
|
||||
this->utime = 0;
|
||||
this->stime = 0;
|
||||
this->comm = NULL;
|
||||
this->indent = 0;
|
||||
if (Process_getuid == -1) Process_getuid = getuid();
|
||||
return this;
|
||||
}
|
||||
@ -141,15 +139,13 @@ Process* Process_new(struct ProcessList_ *pl) {
|
||||
Process* Process_clone(Process* this) {
|
||||
Process* clone = malloc(sizeof(Process));
|
||||
memcpy(clone, this, sizeof(Process));
|
||||
this->comm = NULL;
|
||||
this->pid = 0;
|
||||
return clone;
|
||||
}
|
||||
|
||||
void Process_delete(Object* cast) {
|
||||
Process* this = (Process*) cast;
|
||||
assert (this != NULL);
|
||||
if (this->comm) free(this->comm);
|
||||
assert (this != NULL);
|
||||
free(this);
|
||||
}
|
||||
|
||||
@ -186,26 +182,26 @@ void Process_sendSignal(Process* this, int signal) {
|
||||
#define ONE_M (ONE_K * ONE_K)
|
||||
#define ONE_G (ONE_M * ONE_K)
|
||||
|
||||
static void Process_printLargeNumber(Process* this, RichString *str, unsigned long number) {
|
||||
static void Process_printLargeNumber(Process* this, RichString *str, unsigned int number) {
|
||||
char buffer[11];
|
||||
int len;
|
||||
if(number >= (1000 * ONE_M)) {
|
||||
len = snprintf(buffer, 10, "%4.2fG ", (float)number / ONE_M);
|
||||
RichString_appendn(str, CRT_colors[LARGE_NUMBER], buffer, len);
|
||||
} else if(number >= (100000)) {
|
||||
len = snprintf(buffer, 10, "%4ldM ", number / ONE_K);
|
||||
len = snprintf(buffer, 10, "%4dM ", number / ONE_K);
|
||||
int attr = this->pl->highlightMegabytes
|
||||
? CRT_colors[PROCESS_MEGABYTES]
|
||||
: CRT_colors[PROCESS];
|
||||
RichString_appendn(str, attr, buffer, len);
|
||||
} else if (this->pl->highlightMegabytes && number >= 1000) {
|
||||
len = snprintf(buffer, 10, "%2ld", number/1000);
|
||||
len = snprintf(buffer, 10, "%2d", number/1000);
|
||||
RichString_appendn(str, CRT_colors[PROCESS_MEGABYTES], buffer, len);
|
||||
number %= 1000;
|
||||
len = snprintf(buffer, 10, "%03ld ", number);
|
||||
len = snprintf(buffer, 10, "%03d ", number);
|
||||
RichString_appendn(str, CRT_colors[PROCESS], buffer, len);
|
||||
} else {
|
||||
len = snprintf(buffer, 10, "%5ld ", number);
|
||||
len = snprintf(buffer, 10, "%5d ", number);
|
||||
RichString_appendn(str, CRT_colors[PROCESS], buffer, len);
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ in the source distribution for its full text.
|
||||
|
||||
/*{
|
||||
|
||||
#ifdef DEBUG_PROC
|
||||
#ifdef DEBUG
|
||||
typedef int(*vxscanf)(void*, const char*, va_list);
|
||||
#endif
|
||||
|
||||
@ -118,7 +118,7 @@ typedef struct ProcessList_ {
|
||||
bool highlightBaseName;
|
||||
bool highlightMegabytes;
|
||||
bool expandSystemTime;
|
||||
#ifdef DEBUG_PROC
|
||||
#ifdef DEBUG
|
||||
FILE* traceFile;
|
||||
#endif
|
||||
|
||||
@ -127,7 +127,7 @@ typedef struct ProcessList_ {
|
||||
|
||||
static ProcessField defaultHeaders[] = { PID, USER, PRIORITY, NICE, M_SIZE, M_RESIDENT, M_SHARE, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 };
|
||||
|
||||
#ifdef DEBUG_PROC
|
||||
#ifdef DEBUG
|
||||
|
||||
#define ProcessList_read(this, buffer, format, ...) ProcessList_xread(this, (vxscanf) vsscanf, buffer, format, ## __VA_ARGS__ )
|
||||
#define ProcessList_fread(this, file, format, ...) ProcessList_xread(this, (vxscanf) vfscanf, file, format, ## __VA_ARGS__ )
|
||||
@ -204,14 +204,13 @@ ProcessList* ProcessList_new(UsersTable* usersTable) {
|
||||
this = malloc(sizeof(ProcessList));
|
||||
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->prototype = Process_new(this);
|
||||
this->usersTable = usersTable;
|
||||
|
||||
/* tree-view auxiliary buffers */
|
||||
this->processes2 = Vector_new(PROCESS_CLASS, true, DEFAULT_SIZE, Process_compare);
|
||||
|
||||
#ifdef DEBUG_PROC
|
||||
#ifdef DEBUG
|
||||
this->traceFile = fopen("/tmp/htop-proc-trace", "w");
|
||||
#endif
|
||||
|
||||
@ -263,7 +262,7 @@ void ProcessList_delete(ProcessList* this) {
|
||||
// other fields are offsets of the same buffer
|
||||
free(this->totalTime);
|
||||
|
||||
#ifdef DEBUG_PROC
|
||||
#ifdef DEBUG
|
||||
fclose(this->traceFile);
|
||||
#endif
|
||||
|
||||
@ -298,26 +297,14 @@ void ProcessList_prune(ProcessList* this) {
|
||||
}
|
||||
|
||||
void ProcessList_add(ProcessList* this, Process* p) {
|
||||
assert(Vector_indexOf(this->processes, p, Process_pidCompare) == -1);
|
||||
assert(Hashtable_get(this->processTable, p->pid) == NULL);
|
||||
Vector_add(this->processes, p);
|
||||
Hashtable_put(this->processTable, p->pid, p);
|
||||
assert(Vector_indexOf(this->processes, p, Process_pidCompare) != -1);
|
||||
assert(Hashtable_get(this->processTable, p->pid) != NULL);
|
||||
assert(Hashtable_count(this->processTable) == Vector_count(this->processes));
|
||||
}
|
||||
|
||||
void ProcessList_remove(ProcessList* this, Process* p) {
|
||||
assert(Vector_indexOf(this->processes, p, Process_pidCompare) != -1);
|
||||
assert(Hashtable_get(this->processTable, p->pid) != NULL);
|
||||
Process* pp = Hashtable_remove(this->processTable, p->pid);
|
||||
assert(pp == p); (void)pp;
|
||||
int pid = p->pid;
|
||||
Hashtable_remove(this->processTable, p->pid);
|
||||
int index = Vector_indexOf(this->processes, p, Process_pidCompare);
|
||||
assert(index != -1);
|
||||
Vector_remove(this->processes, index);
|
||||
assert(Hashtable_get(this->processTable, pid) == NULL); (void)pid;
|
||||
assert(Hashtable_count(this->processTable) == Vector_count(this->processes));
|
||||
}
|
||||
|
||||
Process* ProcessList_get(ProcessList* this, int index) {
|
||||
@ -331,22 +318,21 @@ int ProcessList_size(ProcessList* this) {
|
||||
static void ProcessList_buildTree(ProcessList* this, int pid, int level, int indent, int direction) {
|
||||
Vector* children = Vector_new(PROCESS_CLASS, false, DEFAULT_SIZE, Process_compare);
|
||||
|
||||
for (int i = Vector_size(this->processes) - 1; i >= 0; i--) {
|
||||
for (int i = 0; i < Vector_size(this->processes); i++) {
|
||||
Process* process = (Process*) (Vector_get(this->processes, i));
|
||||
if (process->ppid == pid) {
|
||||
Process* process = (Process*) (Vector_take(this->processes, i));
|
||||
Vector_add(children, process);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
int size = Vector_size(children);
|
||||
for (int i = 0; i < size; i++) {
|
||||
Process* process = (Process*) (Vector_get(children, i));
|
||||
int s = this->processes2->items;
|
||||
if (direction == 1)
|
||||
Vector_add(this->processes2, process);
|
||||
else
|
||||
Vector_insert(this->processes2, 0, process);
|
||||
assert(this->processes2->items == s+1); (void)s;
|
||||
int nextIndent = indent;
|
||||
if (i < size - 1)
|
||||
nextIndent = indent | (1 << level);
|
||||
@ -367,19 +353,11 @@ void ProcessList_sort(ProcessList* this) {
|
||||
Vector_sort(this->processes);
|
||||
this->sortKey = sortKey;
|
||||
this->direction = direction;
|
||||
int vsize = Vector_size(this->processes);
|
||||
Process* init = (Process*) (Vector_take(this->processes, 0));
|
||||
assert(init->pid == 1);
|
||||
init->indent = 0;
|
||||
Vector_add(this->processes2, init);
|
||||
ProcessList_buildTree(this, init->pid, 0, 0, direction);
|
||||
while (Vector_size(this->processes)) {
|
||||
Process* p = (Process*) (Vector_take(this->processes, 0));
|
||||
p->indent = 0;
|
||||
Vector_add(this->processes2, p);
|
||||
}
|
||||
assert(Vector_size(this->processes2) == vsize); (void)vsize;
|
||||
assert(Vector_size(this->processes) == 0);
|
||||
Vector* t = this->processes;
|
||||
this->processes = this->processes2;
|
||||
this->processes2 = t;
|
||||
@ -393,7 +371,7 @@ static int ProcessList_readStatFile(ProcessList* this, Process *proc, FILE *f, c
|
||||
int size = fread(buf, 1, MAX_READ, f);
|
||||
if(!size) return 0;
|
||||
|
||||
assert(proc->pid == atoi(buf));
|
||||
proc->pid = atoi(buf);
|
||||
char *location = strchr(buf, ' ');
|
||||
if(!location) return 0;
|
||||
|
||||
@ -406,7 +384,7 @@ static int ProcessList_readStatFile(ProcessList* this, Process *proc, FILE *f, c
|
||||
command[commsize] = '\0';
|
||||
location = end + 2;
|
||||
|
||||
#ifdef DEBUG_PROC
|
||||
#ifdef DEBUG
|
||||
int num = ProcessList_read(this, location,
|
||||
"%c %d %d %d %d %d %lu %lu %lu %lu "
|
||||
"%lu %lu %lu %ld %ld %ld %ld %ld %ld "
|
||||
@ -499,7 +477,7 @@ void ProcessList_processEntries(ProcessList* this, char* dirname, int parent, fl
|
||||
Process* prototype = this->prototype;
|
||||
|
||||
dir = opendir(dirname);
|
||||
if (!dir) return;
|
||||
assert(dir != NULL);
|
||||
while ((entry = readdir(dir)) != NULL) {
|
||||
char* name = entry->d_name;
|
||||
int pid;
|
||||
@ -530,17 +508,14 @@ void ProcessList_processEntries(ProcessList* this, char* dirname, int parent, fl
|
||||
char statusfilename[MAX_NAME+1];
|
||||
char command[PROCESS_COMM_LEN + 1];
|
||||
|
||||
Process* process = NULL;
|
||||
Process* process;
|
||||
|
||||
assert(Hashtable_count(this->processTable) == Vector_count(this->processes));
|
||||
Process* existingProcess = (Process*) Hashtable_get(this->processTable, pid);
|
||||
if (existingProcess) {
|
||||
assert(Vector_indexOf(this->processes, existingProcess, Process_pidCompare) != -1);
|
||||
process = existingProcess;
|
||||
assert(process->pid == pid);
|
||||
} else {
|
||||
process = prototype;
|
||||
assert(process->comm == NULL);
|
||||
process->comm = NULL;
|
||||
process->pid = pid;
|
||||
if (! ProcessList_readStatusFile(this, process, dirname, name))
|
||||
goto errorReadingProcess;
|
||||
@ -612,23 +587,24 @@ void ProcessList_processEntries(ProcessList* this, char* dirname, int parent, fl
|
||||
}
|
||||
|
||||
if (!existingProcess) {
|
||||
ProcessList_add(this, Process_clone(process));
|
||||
process = Process_clone(process);
|
||||
ProcessList_add(this, process);
|
||||
}
|
||||
|
||||
continue;
|
||||
|
||||
// Exception handler.
|
||||
errorReadingProcess: {
|
||||
if (process->comm) {
|
||||
free(process->comm);
|
||||
process->comm = NULL;
|
||||
}
|
||||
if (existingProcess)
|
||||
ProcessList_remove(this, process);
|
||||
assert(Hashtable_count(this->processTable) == Vector_count(this->processes));
|
||||
else {
|
||||
if (process->comm)
|
||||
free(process->comm);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
prototype->comm = NULL;
|
||||
closedir(dir);
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ in the source distribution for its full text.
|
||||
|
||||
|
||||
|
||||
#ifdef DEBUG_PROC
|
||||
#ifdef DEBUG
|
||||
typedef int(*vxscanf)(void*, const char*, va_list);
|
||||
#endif
|
||||
|
||||
@ -118,13 +118,13 @@ typedef struct ProcessList_ {
|
||||
bool highlightBaseName;
|
||||
bool highlightMegabytes;
|
||||
bool expandSystemTime;
|
||||
#ifdef DEBUG_PROC
|
||||
#ifdef DEBUG
|
||||
FILE* traceFile;
|
||||
#endif
|
||||
|
||||
} ProcessList;
|
||||
|
||||
#ifdef DEBUG_PROC
|
||||
#ifdef DEBUG
|
||||
|
||||
#define ProcessList_read(this, buffer, format, ...) ProcessList_xread(this, (vxscanf) vsscanf, buffer, format, ## __VA_ARGS__ )
|
||||
#define ProcessList_fread(this, file, format, ...) ProcessList_xread(this, (vxscanf) vfscanf, file, format, ## __VA_ARGS__ )
|
||||
|
14
Vector.c
14
Vector.c
@ -63,7 +63,6 @@ void Vector_delete(Vector* this) {
|
||||
#ifdef DEBUG
|
||||
|
||||
static inline bool Vector_isConsistent(Vector* this) {
|
||||
assert(this->items <= this->arraySize);
|
||||
if (this->owner) {
|
||||
for (int i = 0; i < this->items; i++)
|
||||
if (this->array[i] && this->array[i]->class != this->vectorType)
|
||||
@ -74,16 +73,6 @@ static inline bool Vector_isConsistent(Vector* this) {
|
||||
}
|
||||
}
|
||||
|
||||
int Vector_count(Vector* this) {
|
||||
int items = 0;
|
||||
for (int i = 0; i < this->items; i++) {
|
||||
if (this->array[i])
|
||||
items++;
|
||||
}
|
||||
assert(items == this->items);
|
||||
return items;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void Vector_prune(Vector* this) {
|
||||
@ -233,9 +222,8 @@ void Vector_add(Vector* this, void* data_) {
|
||||
assert(data_ && ((Object*)data_)->class == this->vectorType);
|
||||
Object* data = data_;
|
||||
assert(Vector_isConsistent(this));
|
||||
int i = this->items;
|
||||
|
||||
Vector_set(this, this->items, data);
|
||||
assert(this->items == i+1); (void)(i);
|
||||
assert(Vector_isConsistent(this));
|
||||
}
|
||||
|
||||
|
2
Vector.h
2
Vector.h
@ -41,8 +41,6 @@ void Vector_delete(Vector* this);
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
int Vector_count(Vector* this);
|
||||
|
||||
#endif
|
||||
|
||||
void Vector_prune(Vector* this);
|
||||
|
@ -2,7 +2,7 @@
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ(2.57)
|
||||
AC_INIT([htop],[0.6.5],[loderunner@users.sourceforge.net])
|
||||
AC_INIT([htop],[0.6.4],[loderunner@users.sourceforge.net])
|
||||
AM_INIT_AUTOMAKE
|
||||
AC_CONFIG_SRCDIR([htop.c])
|
||||
AC_CONFIG_HEADER([config.h])
|
||||
@ -15,7 +15,7 @@ AC_CHECK_LIB([ncurses], [refresh], [], [missing_libraries="$missing_libraries li
|
||||
AC_CHECK_LIB([m], [ceil], [], [missing_libraries="$missing_libraries libm"])
|
||||
|
||||
if test ! -z "$missing_libraries"; then
|
||||
AC_MSG_ERROR([missing libraries: $missing_libraries])
|
||||
AC_MSG_ERROR([missing libraries:$missing_headers])
|
||||
fi
|
||||
|
||||
# Checks for header files.
|
||||
@ -26,7 +26,7 @@ AC_CHECK_HEADERS([stdlib.h string.h strings.h sys/param.h sys/time.h unistd.h cu
|
||||
])
|
||||
|
||||
if test ! -z "$missing_headers"; then
|
||||
AC_MSG_ERROR([missing headers: $missing_headers])
|
||||
AC_MSG_ERROR([missing headers:$missing_headers])
|
||||
fi
|
||||
|
||||
# Checks for typedefs, structures, and compiler characteristics.
|
||||
|
2
htop.1
2
htop.1
@ -1,4 +1,4 @@
|
||||
.TH "htop" "1" "0.6.5" "Bartosz Fenski <fenio@o2.pl>" "Utils"
|
||||
.TH "htop" "1" "0.6.4" "Bartosz Fenski <fenio@o2.pl>" "Utils"
|
||||
.SH "NAME"
|
||||
htop \- interactive process viewer
|
||||
.SH "SYNTAX"
|
||||
|
53
htop.c
53
htop.c
@ -93,36 +93,35 @@ void showHelp(ProcessList* pl) {
|
||||
addattrstr(CRT_colors[BAR_BORDER], "]");
|
||||
attrset(CRT_colors[DEFAULT_COLOR]);
|
||||
mvaddstr(6,0, "Type and layout of header meters are configurable in the setup screen.");
|
||||
mvaddstr(7, 0, "Status: R: running; S: sleeping; T: traced/stopped; Z: zombie; D: disk sleep");
|
||||
|
||||
mvaddstr( 9, 0, " Arrows: scroll process list F5 t: tree view");
|
||||
mvaddstr(10, 0, " Digits: incremental PID search u: show processes of a single user");
|
||||
mvaddstr(11, 0, " F3 /: incremental name search H: hide/show user threads");
|
||||
mvaddstr(12, 0, " K: hide/show kernel threads");
|
||||
mvaddstr(13, 0, " Space: tag processes F: cursor follows process");
|
||||
mvaddstr(14, 0, " U: untag all processes");
|
||||
mvaddstr(15, 0, " F9 k: kill process/tagged processes P: sort by CPU%");
|
||||
mvaddstr(16, 0, " + [ F7: lower priority (+ nice) M: sort by MEM%");
|
||||
mvaddstr(17, 0, " - ] F8: higher priority (root only) T: sort by TIME");
|
||||
mvaddstr(18, 0, " F4 I: invert sort order");
|
||||
mvaddstr(19, 0, " F2 S: setup F6 >: select sort column");
|
||||
mvaddstr(20, 0, " F1 h: show this help screen");
|
||||
mvaddstr(21, 0, " F10 q: quit s: trace syscalls with strace");
|
||||
mvaddstr( 8, 0, " Arrows: scroll process list F5 t: tree view");
|
||||
mvaddstr( 9, 0, " Digits: incremental PID search u: show processes of a single user");
|
||||
mvaddstr(10, 0, " F3 /: incremental name search H: hide/show user threads");
|
||||
mvaddstr(11, 0, " K: hide/show kernel threads");
|
||||
mvaddstr(12, 0, " Space: tag processes F: cursor follows process");
|
||||
mvaddstr(13, 0, " U: untag all processes");
|
||||
mvaddstr(14, 0, " F9 k: kill process/tagged processes P: sort by CPU%");
|
||||
mvaddstr(15, 0, " + [ F7: lower priority (+ nice) M: sort by MEM%");
|
||||
mvaddstr(16, 0, " - ] F8: higher priority (root only) T: sort by TIME");
|
||||
mvaddstr(17, 0, " F4 I: invert sort order");
|
||||
mvaddstr(18, 0, " F2 S: setup F6 >: select sort column");
|
||||
mvaddstr(19, 0, " F1 h: show this help screen");
|
||||
mvaddstr(20, 0, " F10 q: quit s: trace syscalls with strace");
|
||||
|
||||
attrset(CRT_colors[HELP_BOLD]);
|
||||
mvaddstr( 9, 0, " Arrows"); mvaddstr( 9,40, " F5 t");
|
||||
mvaddstr(10, 0, " Digits"); mvaddstr(10,40, " u");
|
||||
mvaddstr(11, 0, " F3 /"); mvaddstr(11,40, " H");
|
||||
mvaddstr(12,40, " K");
|
||||
mvaddstr(13, 0, " Space"); mvaddstr(13,40, " F");
|
||||
mvaddstr(14, 0, " U");
|
||||
mvaddstr(15, 0, " F9 k"); mvaddstr(15,40, " P");
|
||||
mvaddstr(16, 0, " + [ F7"); mvaddstr(16,40, " M");
|
||||
mvaddstr(17, 0, " - ] F8"); mvaddstr(17,40, " T");
|
||||
mvaddstr(18,40, " F4 I");
|
||||
mvaddstr(19, 0, " F2 S"); mvaddstr(19,40, " F6 >");
|
||||
mvaddstr(20, 0, " F1 h");
|
||||
mvaddstr(21, 0, " F10 q"); mvaddstr(21,40, " s");
|
||||
mvaddstr( 8, 0, " Arrows"); mvaddstr( 8,40, " F5 t");
|
||||
mvaddstr( 9, 0, " Digits"); mvaddstr( 9,40, " u");
|
||||
mvaddstr(10, 0, " F3 /"); mvaddstr(10,40, " H");
|
||||
mvaddstr(11,40, " K");
|
||||
mvaddstr(12, 0, " Space"); mvaddstr(12,40, " F");
|
||||
mvaddstr(13, 0, " U");
|
||||
mvaddstr(14, 0, " F9 k"); mvaddstr(14,40, " P");
|
||||
mvaddstr(15, 0, " + [ F7"); mvaddstr(15,40, " M");
|
||||
mvaddstr(16, 0, " - ] F8"); mvaddstr(16,40, " T");
|
||||
mvaddstr(17,40, " F4 I");
|
||||
mvaddstr(18, 0, " F2 S"); mvaddstr(18,40, " F6 >");
|
||||
mvaddstr(19, 0, " F1 h");
|
||||
mvaddstr(20, 0, " F10 q"); mvaddstr(20,40, " s");
|
||||
attrset(CRT_colors[DEFAULT_COLOR]);
|
||||
|
||||
attrset(CRT_colors[HELP_BOLD]);
|
||||
|
@ -1,6 +1,6 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Version=0.6.5
|
||||
Version=0.6.4
|
||||
Name=Htop
|
||||
Type=Application
|
||||
Comment=Show System Processes
|
||||
|
Reference in New Issue
Block a user