Give the MEMORY_MODE enum a name.
This improves readability. Also, set the default value in one place in the declaration.
This commit is contained in:
parent
c5f369ae00
commit
4fd854ce16
@ -93,7 +93,7 @@ int main( int argc, char** argv )
|
||||
unsigned cpu_usage_delay = 990000;
|
||||
short graph_lines = 10; // max 32767 should be enough
|
||||
bool use_colors = false;
|
||||
int mem_mode = MEMORY_MODE_DEFAULT;
|
||||
MEMORY_MODE mem_mode = MEMORY_MODE_DEFAULT;
|
||||
|
||||
static struct option long_options[] =
|
||||
{
|
||||
@ -143,7 +143,7 @@ int main( int argc, char** argv )
|
||||
std::cerr << "Memory mode argument must be zero or greater.\n";
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
mem_mode = atoi( optarg );
|
||||
mem_mode = static_cast< MEMORY_MODE >( atoi( optarg ) );
|
||||
break;
|
||||
case '?':
|
||||
// getopt_long prints error message automatically
|
||||
|
@ -21,13 +21,14 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
enum
|
||||
enum MEMORY_MODE
|
||||
{
|
||||
MEMORY_MODE_DEFAULT,
|
||||
MEMORY_MODE_FREE_MEMORY,
|
||||
MEMORY_MODE_USAGE_PERCENTAGE
|
||||
};
|
||||
|
||||
std::string mem_string( bool, int );
|
||||
std::string mem_string( bool,
|
||||
MEMORY_MODE mode = MEMORY_MODE_DEFAULT );
|
||||
|
||||
#endif
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "luts.h"
|
||||
#include "conversions.h"
|
||||
|
||||
std::string mem_string( bool use_colors = false, int mode = 0 )
|
||||
std::string mem_string( bool use_colors = false, MEMORY_MODE mode )
|
||||
{
|
||||
// These values are in bytes
|
||||
//u_int total;
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "luts.h"
|
||||
#include "conversions.h"
|
||||
|
||||
std::string mem_string( bool use_colors = false, int mode = 0 )
|
||||
std::string mem_string( bool use_colors = false, MEMORY_MODE mode )
|
||||
{
|
||||
using std::string;
|
||||
using std::ifstream;
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "conversions.h"
|
||||
#include "memory.h"
|
||||
|
||||
std::string mem_string( bool use_colors = false, int mode = 0 )
|
||||
std::string mem_string( bool use_colors = false, MEMORY_MODE mode )
|
||||
{
|
||||
std::ostringstream oss;
|
||||
|
||||
|
@ -47,7 +47,7 @@ static int pageshift;
|
||||
#endif
|
||||
#define pagesh(size) ((size) << pageshift)
|
||||
|
||||
std::string mem_string( bool use_colors = false, int mode = 0 )
|
||||
std::string mem_string( bool use_colors = false, MEMORY_MODE mode )
|
||||
{
|
||||
std::ostringstream oss;
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "luts.h"
|
||||
#include "conversions.h"
|
||||
|
||||
std::string mem_string( bool use_colors, int mode )
|
||||
std::string mem_string( bool use_colors, MEMORY_MODE mode )
|
||||
{
|
||||
std::ostringstream oss;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user