mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-12-22 08:48:55 +00:00
Specify deleter function for regex_t unique_ptr (#2536)
This commit is contained in:
parent
e80de15cc6
commit
bbbb2d0908
@ -119,7 +119,7 @@ bool AdditionalHeader::Load(const char* file)
|
||||
key.erase(0, strlen(ADD_HEAD_REGEX));
|
||||
|
||||
// compile
|
||||
std::unique_ptr<regex_t> preg(new regex_t);
|
||||
RegexPtr preg(new regex_t, regfree);
|
||||
int result;
|
||||
if(0 != (result = regcomp(preg.get(), key.c_str(), REG_EXTENDED | REG_NOSUB))){ // we do not need matching info
|
||||
char errbuf[256];
|
||||
@ -131,7 +131,7 @@ bool AdditionalHeader::Load(const char* file)
|
||||
addheadlist.emplace_back(std::move(preg), key, head, value);
|
||||
}else{
|
||||
// not regex, directly comparing
|
||||
addheadlist.emplace_back(nullptr, key, head, value);
|
||||
addheadlist.emplace_back(RegexPtr(nullptr, regfree), key, head, value);
|
||||
}
|
||||
|
||||
// set flag
|
||||
|
@ -30,25 +30,22 @@
|
||||
//----------------------------------------------
|
||||
// Structure / Typedef
|
||||
//----------------------------------------------
|
||||
typedef std::unique_ptr<regex_t, decltype(®free)> RegexPtr;
|
||||
|
||||
struct add_header{
|
||||
add_header(std::unique_ptr<regex_t> pregex, std::string basestring, std::string headkey, std::string headvalue)
|
||||
add_header(RegexPtr pregex, std::string basestring, std::string headkey, std::string headvalue)
|
||||
: pregex(std::move(pregex))
|
||||
, basestring(std::move(basestring))
|
||||
, headkey(std::move(headkey))
|
||||
, headvalue(std::move(headvalue))
|
||||
{}
|
||||
~add_header() {
|
||||
if(pregex){
|
||||
regfree(pregex.get());
|
||||
}
|
||||
}
|
||||
|
||||
add_header(const add_header&) = delete;
|
||||
add_header(add_header&& val) = default;
|
||||
add_header& operator=(const add_header&) = delete;
|
||||
add_header& operator=(add_header&&) = delete;
|
||||
|
||||
std::unique_ptr<regex_t> pregex; // not nullptr means using regex, nullptr means comparing suffix directly.
|
||||
RegexPtr pregex; // not nullptr means using regex, nullptr means comparing suffix directly.
|
||||
std::string basestring;
|
||||
std::string headkey;
|
||||
std::string headvalue;
|
||||
|
Loading…
Reference in New Issue
Block a user