mirror of https://github.com/xzeldon/htop.git
Introduce ARRAYSIZE
This commit is contained in:
parent
b82a13c6ba
commit
42946ec113
4
Macros.h
4
Macros.h
|
@ -13,6 +13,10 @@
|
||||||
#define CLAMP(x, low, high) (((x) > (high)) ? (high) : MAXIMUM(x, low))
|
#define CLAMP(x, low, high) (((x) > (high)) ? (high) : MAXIMUM(x, low))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef ARRAYSIZE
|
||||||
|
#define ARRAYSIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __GNUC__ // defined by GCC and Clang
|
#ifdef __GNUC__ // defined by GCC and Clang
|
||||||
|
|
||||||
#define ATTR_FORMAT(type, index, check) __attribute__((format (type, index, check)))
|
#define ATTR_FORMAT(type, index, check) __attribute__((format (type, index, check)))
|
||||||
|
|
|
@ -20,7 +20,7 @@ in the source distribution for its full text.
|
||||||
void Settings_delete(Settings* this) {
|
void Settings_delete(Settings* this) {
|
||||||
free(this->filename);
|
free(this->filename);
|
||||||
free(this->fields);
|
free(this->fields);
|
||||||
for (unsigned int i = 0; i < (sizeof(this->columns)/sizeof(MeterColumnSettings)); i++) {
|
for (unsigned int i = 0; i < ARRAYSIZE(this->columns); i++) {
|
||||||
String_freeArray(this->columns[i].names);
|
String_freeArray(this->columns[i].names);
|
||||||
free(this->columns[i].modes);
|
free(this->columns[i].modes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ void CRT_handleSIGSEGV(int sgn) {
|
||||||
#ifdef __linux
|
#ifdef __linux
|
||||||
fprintf(stderr, "\n\nhtop " VERSION " aborting. Please report bug at https://htop.dev\n");
|
fprintf(stderr, "\n\nhtop " VERSION " aborting. Please report bug at https://htop.dev\n");
|
||||||
#ifdef HAVE_EXECINFO_H
|
#ifdef HAVE_EXECINFO_H
|
||||||
size_t size = backtrace(backtraceArray, sizeof(backtraceArray) / sizeof(void *));
|
size_t size = backtrace(backtraceArray, ARRAYSIZE(backtraceArray));
|
||||||
fprintf(stderr, "\n Please include in your report the following backtrace: \n");
|
fprintf(stderr, "\n Please include in your report the following backtrace: \n");
|
||||||
backtrace_symbols_fd(backtraceArray, size, 2);
|
backtrace_symbols_fd(backtraceArray, size, 2);
|
||||||
fprintf(stderr, "\nAdditionally, in order to make the above backtrace useful,");
|
fprintf(stderr, "\nAdditionally, in order to make the above backtrace useful,");
|
||||||
|
|
|
@ -79,7 +79,7 @@ const SignalItem Platform_signals[] = {
|
||||||
{ .name = "31 SIGSYS", .number = 31 },
|
{ .name = "31 SIGSYS", .number = 31 },
|
||||||
};
|
};
|
||||||
|
|
||||||
const unsigned int Platform_numberOfSignals = sizeof(Platform_signals)/sizeof(SignalItem);
|
const unsigned int Platform_numberOfSignals = ARRAYSIZE(Platform_signals);
|
||||||
|
|
||||||
static Htop_Reaction Platform_actionSetIOPriority(State* st) {
|
static Htop_Reaction Platform_actionSetIOPriority(State* st) {
|
||||||
Panel* panel = st->panel;
|
Panel* panel = st->panel;
|
||||||
|
|
Loading…
Reference in New Issue