use a wrapper to make std::unique_ptr less verbose

This commit is contained in:
Daniel Micay 2012-10-04 15:35:48 -04:00
parent 3d2c98b162
commit 506166230c
2 changed files with 13 additions and 1 deletions

11
memory.hh Normal file
View File

@ -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

View File

@ -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) {