Save text buffer in Meter

This commit is contained in:
Christian Göttsche
2020-10-06 13:13:16 +02:00
committed by BenBE
parent 23c5b9ce3c
commit 2d1042adb3
23 changed files with 73 additions and 68 deletions

View File

@ -31,9 +31,11 @@ static const char* const HugePageMeter_labels[] = {
" 1G:", " 2G:", " 4G:", " 8G:", " 16G:", " 32G:", " 64G:", " 128G:", " 256G:", " 512G:",
};
static void HugePageMeter_updateValues(Meter* this, char* buffer, size_t size) {
static void HugePageMeter_updateValues(Meter* this) {
assert(ARRAYSIZE(HugePageMeter_labels) == HTOP_HUGEPAGE_COUNT);
char* buffer = this->txtBuffer;
size_t size = sizeof(this->txtBuffer);
int written;
memory_t usedTotal = 0;
unsigned nextUsed = 0;

View File

@ -25,7 +25,7 @@ static const int PressureStallMeter_attributes[] = {
PRESSURE_STALL_THREEHUNDRED
};
static void PressureStallMeter_updateValues(Meter* this, char* buffer, size_t len) {
static void PressureStallMeter_updateValues(Meter* this) {
const char* file;
if (strstr(Meter_name(this), "CPU")) {
file = "cpu";
@ -47,7 +47,7 @@ static void PressureStallMeter_updateValues(Meter* this, char* buffer, size_t le
/* only print bar for ten (not sixty and threehundred), cause the sum is meaningless */
this->curItems = 1;
xSnprintf(buffer, len, "%s %s %5.2lf%% %5.2lf%% %5.2lf%%", some ? "some" : "full", file, this->values[0], this->values[1], this->values[2]);
xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "%s %s %5.2lf%% %5.2lf%% %5.2lf%%", some ? "some" : "full", file, this->values[0], this->values[1], this->values[2]);
}
static void PressureStallMeter_display(const Object* cast, RichString* out) {

View File

@ -69,11 +69,11 @@ static bool isSelinuxEnforcing(void) {
return !!enforce;
}
static void SELinuxMeter_updateValues(ATTR_UNUSED Meter* this, char* buffer, size_t len) {
static void SELinuxMeter_updateValues(ATTR_UNUSED Meter* this) {
enabled = isSelinuxEnabled();
enforcing = isSelinuxEnforcing();
xSnprintf(buffer, len, "%s%s", enabled ? "enabled" : "disabled", enabled ? (enforcing ? "; mode: enforcing" : "; mode: permissive") : "");
xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "%s%s", enabled ? "enabled" : "disabled", enabled ? (enforcing ? "; mode: enforcing" : "; mode: permissive") : "");
}
const MeterClass SELinuxMeter_class = {

View File

@ -262,7 +262,7 @@ static void updateViaExec(void) {
fclose(commandOutput);
}
static void SystemdMeter_updateValues(ATTR_UNUSED Meter* this, char* buffer, size_t size) {
static void SystemdMeter_updateValues(Meter* this) {
free(systemState);
systemState = NULL;
nFailedUnits = nInstalledJobs = nNames = nJobs = INVALID_VALUE;
@ -274,7 +274,7 @@ static void SystemdMeter_updateValues(ATTR_UNUSED Meter* this, char* buffer, siz
updateViaExec();
#endif /* !BUILD_STATIC || HAVE_LIBSYSTEMD */
xSnprintf(buffer, size, "%s", systemState ? systemState : "???");
xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "%s", systemState ? systemState : "???");
}
static int zeroDigitColor(unsigned int value) {

View File

@ -11,7 +11,9 @@ static const int ZramMeter_attributes[] = {
ZRAM
};
static void ZramMeter_updateValues(Meter* this, char* buffer, size_t size) {
static void ZramMeter_updateValues(Meter* this) {
char* buffer = this->txtBuffer;
size_t size = sizeof(this->txtBuffer);
int written;
Platform_setZramValues(this);