use a wrapper to make std::unique_ptr less verbose
This commit is contained in:
parent
3d2c98b162
commit
506166230c
|
@ -0,0 +1,11 @@
|
|||
#ifndef MEMORY_HH
|
||||
#define MEMORY_HH
|
||||
|
||||
#include <memory>
|
||||
|
||||
template<typename T, typename Deleter>
|
||||
std::unique_ptr<T, Deleter> make_unique(T *p, Deleter d) {
|
||||
return std::unique_ptr<T, Deleter>(p, d);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -12,6 +12,7 @@
|
|||
#include <vte/vte.h>
|
||||
#include <vte/vteaccess.h>
|
||||
|
||||
#include "memory.hh"
|
||||
#include "url_regex.hh"
|
||||
|
||||
using namespace std::placeholders;
|
||||
|
@ -133,7 +134,7 @@ static void find_urls(VteTerminal *vte, search_panel_info *panel_info) {
|
|||
}
|
||||
|
||||
static void launch_url(const char *text, search_panel_info *info) {
|
||||
std::unique_ptr<char, decltype(&free)> copy(strdup(text), free);
|
||||
auto copy = make_unique(strdup(text), free);
|
||||
for (char *s_ptr = copy.get(), *saveptr; ; s_ptr = nullptr) {
|
||||
const char *token = strtok_r(s_ptr, ",", &saveptr);
|
||||
if (!token) {
|
||||
|
|
Loading…
Reference in New Issue