47 int numswap = swapctl(SC_GETNSWP, NULL);
49 std::cerr <<
"Can not determine number of swap spaces." << std::endl;
54 swaps = (swaptbl_t *)malloc(
sizeof(swaptbl_t) + numswap *
sizeof(swapent_t));
55 names = (
char *)calloc(numswap + 1, PATH_MAX);
56 if (!swaps || !names) {
57 std::cerr <<
"malloc failed." << std::endl;
61 swaps->swt_n = numswap;
62 for (
int i = 0; i <= numswap; i++)
63 swaps->swt_ent[i].ste_path = names + (i * PATH_MAX);
65 if (swapctl(SC_LIST, swaps) < 0) {
66 std::cerr <<
"Can not get list of swap spaces." << std::endl;
70 for (
int i = 0; i < numswap; i++) {
71 total_ += swaps->swt_ent[i].ste_pages;
72 fields_[1] += swaps->swt_ent[i].ste_free;
73 XOSDEBUG(
"%s: %ld kB (%ld kB free)\n",
74 swaps->swt_ent[i].ste_path,
75 swaps->swt_ent[i].ste_pages * (
pagesize / 1024),
76 swaps->swt_ent[i].ste_free * (
pagesize / 1024));
virtual void drawfields(int mandatory=0)
virtual void checkResources(void)
void setfieldcolor(int field, const char *color)
void setUsed(double val, double total)
void SetUsedFormat(const char *const str)
void checkResources(void)
SwapMeter(XOSView *parent)
int isResourceTrue(const char *name)
const char * getResource(const char *name)