refactor(common): Cleanup

This commit is contained in:
Michael Carlberg 2017-01-11 05:10:51 +01:00
parent c2bee14d34
commit 5b33ada576
6 changed files with 22 additions and 15 deletions

View File

@ -1,6 +1,7 @@
#pragma once
#include <chrono>
#include <cstdlib>
#include <arpa/inet.h>
#include <ifaddrs.h>

View File

@ -3,6 +3,7 @@
#include <memory>
#include <string>
#include <vector>
#include <functional>
#define POLYBAR_NS \
namespace polybar { \
@ -19,22 +20,12 @@
#define PIPE_WRITE 1
#endif
#ifndef STDOUT_FILENO
#define STDOUT_FILENO 1
#endif
#ifndef STDERR_FILENO
#define STDERR_FILENO 2
#endif
POLYBAR_NS
namespace placeholders = std::placeholders;
using std::string;
using std::stringstream;
using std::size_t;
using std::move;
using std::bind;
using std::forward;
using std::pair;
using std::function;

View File

@ -7,6 +7,13 @@
#include "common.hpp"
#ifndef STDOUT_FILENO
#define STDOUT_FILENO 1
#endif
#ifndef STDERR_FILENO
#define STDERR_FILENO 2
#endif
POLYBAR_NS
enum class loglevel : uint8_t {

View File

@ -1,6 +1,6 @@
#pragma once
#include <cstring>
#include <cstdlib>
#include "common.hpp"
@ -13,8 +13,8 @@ namespace memory_util {
/**
* Create a shared pointer using malloc/free
*/
template <typename T, size_t Size = sizeof(T), typename Deleter = decltype(free)>
inline malloc_ptr_t<T> make_malloc_ptr(Deleter deleter = free) {
template <typename T, size_t Size = sizeof(T), typename Deleter = decltype(std::free)>
inline malloc_ptr_t<T> make_malloc_ptr(Deleter deleter = std::free) {
return malloc_ptr_t<T>(static_cast<T*>(calloc(1, Size)), deleter);
}

View File

@ -1,6 +1,7 @@
#include <sys/wait.h>
#include <unistd.h>
#include <csignal>
#include <cstdlib>
#include <utility>
#include "errors.hpp"
@ -8,6 +9,13 @@
#include "utils/io.hpp"
#include "utils/process.hpp"
#ifndef STDOUT_FILENO
#define STDOUT_FILENO 1
#endif
#ifndef STDERR_FILENO
#define STDERR_FILENO 2
#endif
POLYBAR_NS
command::command(const logger& logger, string cmd) : m_log(logger), m_cmd(move(cmd)) {

View File

@ -67,8 +67,8 @@ int main() {
};
"round_to_nearest_5"_test = [] {
expect(math_util::nearest_5(52) == 55);
expect(math_util::nearest_5(9.1) == 5);
expect(math_util::nearest_5(52) == 50);
expect(math_util::nearest_5(9.1) == 10);
expect(math_util::nearest_5(95.0) == 95);
expect(math_util::nearest_5(94.9) == 95);
expect(math_util::nearest_5(1) == 0);