40 lines
582 B
C
40 lines
582 B
C
|
#include <stdlib.h>
|
||
|
#include "processes.h"
|
||
|
|
||
|
typedef unsigned int uint;
|
||
|
typedef unsigned long int ulong;
|
||
|
|
||
|
const ulong INIT_CAP = 1024;
|
||
|
|
||
|
struct process {
|
||
|
uint pid;
|
||
|
uint ppid;
|
||
|
char user[9];
|
||
|
double priority;
|
||
|
ulong resident_size;
|
||
|
ulong size;
|
||
|
ulong virtual_size;
|
||
|
char command[16];
|
||
|
};
|
||
|
|
||
|
struct processes {
|
||
|
ulong size;
|
||
|
ulong capacity;
|
||
|
struct process procs[];
|
||
|
};
|
||
|
|
||
|
struct processes* new_processes() {
|
||
|
struct processes* p = malloc(sizeof(struct processes) + INIT_CAP *
|
||
|
sizeof(struct process));
|
||
|
if (!p) {
|
||
|
return NULL;
|
||
|
}
|
||
|
|
||
|
p->size = 0;
|
||
|
p->capacity = INTT_CAP;
|
||
|
return p;
|
||
|
}
|
||
|
|
||
|
|
||
|
|