1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-10-27 05:23:39 -04:00
polybar/include/utils/memory.hpp
2016-10-10 14:52:57 +02:00

25 lines
449 B
C++

#pragma once
#include "common.hpp"
LEMONBUDDY_NS
namespace memory_util {
/**
* Create a shared pointer using malloc/free
*/
template <typename T>
inline auto make_malloc_ptr(size_t size = sizeof(T)) {
return shared_ptr<T>(static_cast<T*>(malloc(size)), free);
}
/**
* Get the number of elements in T
*/
template <typename T>
inline auto countof(T& p) {
return sizeof(p) / sizeof(p[0]);
}
}
LEMONBUDDY_NS_END