src: Updating code style to conform (more or less) to ndn-cxx style
Also, adding .clang-format that describes the applied style. Note that
this style requires a slightly customized version of clang-format.
diff --git a/utils/mem-usage.hpp b/utils/mem-usage.hpp
index a18448a..e58b9ad 100644
--- a/utils/mem-usage.hpp
+++ b/utils/mem-usage.hpp
@@ -42,58 +42,53 @@
* @ingroup ndn-helpers
* @brief Utility class to evaluate current usage of RAM
*/
-class MemUsage
-{
+class MemUsage {
public:
/**
* @brief Get memory utilization in bytes
*/
- static inline
- int64_t
- Get ()
+ static inline int64_t
+ Get()
{
#if defined(__linux__)
-/*
-/proc/[pid]/statm
- Provides information about memory usage, measured in pages. The
- columns are:
+ /*
+ /proc/[pid]/statm
+ Provides information about memory usage, measured in pages. The
+ columns are:
- size (1) total program size
- (same as VmSize in /proc/[pid]/status)
- resident (2) resident set size
- (same as VmRSS in /proc/[pid]/status)
- share (3) shared pages (i.e., backed by a file)
- text (4) text (code)
- lib (5) library (unused in Linux 2.6)
- data (6) data + stack
- dt (7) dirty pages (unused in Linux 2.6)
+ size (1) total program size
+ (same as VmSize in /proc/[pid]/status)
+ resident (2) resident set size
+ (same as VmRSS in /proc/[pid]/status)
+ share (3) shared pages (i.e., backed by a file)
+ text (4) text (code)
+ lib (5) library (unused in Linux 2.6)
+ data (6) data + stack
+ dt (7) dirty pages (unused in Linux 2.6)
-Reference: http://man7.org/linux/man-pages/man5/proc.5.html
-*/
- std::ifstream is ("/proc/self/statm");
- if (!is.bad () && !is.eof ())
- {
- unsigned long vm;
- unsigned long rss;
- is >> vm // the first number: virtual memory
- >> rss; // the second number: resident set size
-
- return rss * getpagesize ();
- }
- else
- {
- return -1;
- }
+ Reference: http://man7.org/linux/man-pages/man5/proc.5.html
+ */
+ std::ifstream is("/proc/self/statm");
+ if (!is.bad() && !is.eof()) {
+ unsigned long vm;
+ unsigned long rss;
+ is >> vm // the first number: virtual memory
+ >> rss; // the second number: resident set size
+
+ return rss * getpagesize();
+ }
+ else {
+ return -1;
+ }
#elif defined(__APPLE__)
struct task_basic_info t_info;
mach_msg_type_number_t t_info_count = TASK_BASIC_INFO_COUNT;
- if (KERN_SUCCESS != task_info (mach_task_self (),
- TASK_BASIC_INFO, (task_info_t)&t_info, &t_info_count))
- {
- return -1; // something is wrong
- }
+ if (KERN_SUCCESS
+ != task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)&t_info, &t_info_count)) {
+ return -1; // something is wrong
+ }
return t_info.resident_size;
#endif