MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / Incref

Method Incref

extern/re2/re2/regexp.cc:90–113  ·  view source on GitHub ↗

Increments reference count, returns object as convenience.

Source from the content-addressed store, hash-verified

88
89// Increments reference count, returns object as convenience.
90Regexp* Regexp::Incref() {
91 if (ref_ >= kMaxRef-1) {
92 static std::once_flag ref_once;
93 std::call_once(ref_once, []() {
94 ref_mutex = new Mutex;
95 ref_map = new std::map<Regexp*, int>;
96 });
97
98 // Store ref count in overflow map.
99 MutexLock l(ref_mutex);
100 if (ref_ == kMaxRef) {
101 // already overflowed
102 (*ref_map)[this]++;
103 } else {
104 // overflowing now
105 (*ref_map)[this] = kMaxRef;
106 ref_ = kMaxRef;
107 }
108 return this;
109 }
110
111 ref_++;
112 return this;
113}
114
115// Decrements reference count and deletes this object if count reaches 0.
116void Regexp::Decref() {

Callers 2

StarPlusOrQuestMethod · 0.45
RequiredPrefixMethod · 0.45

Calls 1

call_onceFunction · 0.50

Tested by

no test coverage detected