#pragma once #include #include "common.hpp" POLYBAR_NS namespace memory_util { /** * Create a shared pointer using malloc/free */ template inline auto make_malloc_ptr(size_t size = sizeof(T), Deleter deleter = free) { shared_ptr ptr{static_cast(malloc(size)), deleter}; memset(ptr.get(), 0, size); return ptr; } /** * Get the number of elements in T */ template inline auto countof(T& p) { return sizeof(p) / sizeof(p[0]); } template using malloc_ptr_t = shared_ptr; } POLYBAR_NS_END