]> git.ipfire.org Git - thirdparty/squid.git/blob - src/base/RegexPattern.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / base / RegexPattern.cc
1 /*
2 * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9 #include "squid.h"
10 #include "base/RegexPattern.h"
11 #include <utility>
12
13 RegexPattern::RegexPattern(int aFlags, const char *aPattern) :
14 flags(aFlags),
15 pattern(xstrdup(aPattern))
16 {
17 memset(&regex, 0, sizeof(regex));
18 }
19
20 RegexPattern::RegexPattern(RegexPattern &&o) :
21 flags(std::move(o.flags)),
22 regex(std::move(o.regex)),
23 pattern(std::move(o.pattern))
24 {
25 memset(&o.regex, 0, sizeof(o.regex));
26 o.pattern = nullptr;
27 }
28
29 RegexPattern::~RegexPattern()
30 {
31 xfree(pattern);
32 regfree(&regex);
33 }
34
35 RegexPattern &
36 RegexPattern::operator =(RegexPattern &&o)
37 {
38 flags = std::move(o.flags);
39 regex = std::move(o.regex);
40 memset(&o.regex, 0, sizeof(o.regex));
41 pattern = std::move(o.pattern);
42 o.pattern = nullptr;
43 return *this;
44 }
45