diff options
author | Daniel Lange <DLange@git.local> | 2016-04-11 13:00:29 +0200 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2016-04-11 13:00:29 +0200 |
commit | eaf11cc12a1aa4b050a8a1e7ea3770d3d9c81e95 (patch) | |
tree | 833f3fae6e3604a439f909c245a6e35f574997d7 /Affinity.c | |
parent | 283707c5e5bc436b78ea23bf5500cb6b16a01148 (diff) | |
download | debian_htop-eaf11cc12a1aa4b050a8a1e7ea3770d3d9c81e95.tar.gz debian_htop-eaf11cc12a1aa4b050a8a1e7ea3770d3d9c81e95.tar.bz2 debian_htop-eaf11cc12a1aa4b050a8a1e7ea3770d3d9c81e95.zip |
Imported Upstream version 1.0upstream/1.0
Diffstat (limited to 'Affinity.c')
-rw-r--r-- | Affinity.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Affinity.c b/Affinity.c new file mode 100644 index 0000000..0b2bd46 --- /dev/null +++ b/Affinity.c @@ -0,0 +1,36 @@ + +#include "config.h" +#include "Affinity.h" +#include <stdlib.h> + +/*{ + +typedef struct Affinity_ { + int size; + int used; + int* cpus; +} Affinity; + +}*/ + +Affinity* Affinity_new() { + Affinity* this = calloc(sizeof(Affinity), 1); + this->size = 8; + this->cpus = calloc(sizeof(int), this->size); + return this; +} + +void Affinity_delete(Affinity* this) { + free(this->cpus); + free(this); +} + +void Affinity_add(Affinity* this, int id) { + if (this->used == this->size) { + this->size *= 2; + this->cpus = realloc(this->cpus, sizeof(int) * this->size); + } + this->cpus[this->used] = id; + this->used++; +} + |