summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--WORKSPACE1
-rw-r--r--re2/dfa.cc6
-rw-r--r--re2/onepass.cc4
-rw-r--r--re2/re2.h5
4 files changed, 11 insertions, 5 deletions
diff --git a/WORKSPACE b/WORKSPACE
index 393f5e6..de481fe 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -3,3 +3,4 @@
# license that can be found in the LICENSE file.
# Bazel (http://bazel.io/) WORKSPACE file for RE2.
+workspace(name = "com_googlesource_code_re2")
diff --git a/re2/dfa.cc b/re2/dfa.cc
index e30aeaf..e33bb01 100644
--- a/re2/dfa.cc
+++ b/re2/dfa.cc
@@ -101,7 +101,7 @@ class DFA {
uint flag_; // Empty string bitfield flags in effect on the way
// into this state, along with kFlagMatch if this
// is a matching state.
- std::atomic<State*> next_[1]; // Outgoing arrows from State,
+ std::atomic<State*> next_[]; // Outgoing arrows from State,
// one per input byte class
};
@@ -469,7 +469,7 @@ DFA::DFA(Prog* prog, Prog::MatchKind kind, int64 max_mem)
// Note that a state stores list heads only, so we use the program
// list count for the upper bound, not the program size.
int nnext = prog_->bytemap_range() + 1; // + 1 for kByteEndText slot
- int64 one_state = sizeof(State) + (nnext-1)*sizeof(std::atomic<State*>) +
+ int64 one_state = sizeof(State) + nnext*sizeof(std::atomic<State*>) +
(prog_->list_count()+nmark)*sizeof(int);
if (state_budget_ < 20*one_state) {
LOG(INFO) << StringPrintf("DFA out of memory: prog size %d mem %lld",
@@ -740,7 +740,7 @@ DFA::State* DFA::CachedState(int* inst, int ninst, uint flag) {
// State*, empirically.
const int kStateCacheOverhead = 32;
int nnext = prog_->bytemap_range() + 1; // + 1 for kByteEndText slot
- int mem = sizeof(State) + (nnext-1)*sizeof(std::atomic<State*>) +
+ int mem = sizeof(State) + nnext*sizeof(std::atomic<State*>) +
ninst*sizeof(int);
if (mem_budget_ < mem + kStateCacheOverhead) {
mem_budget_ = -1;
diff --git a/re2/onepass.cc b/re2/onepass.cc
index 1d745d4..a6e3321 100644
--- a/re2/onepass.cc
+++ b/re2/onepass.cc
@@ -131,7 +131,7 @@ static const int Debug = 0;
// the memory footprint.)
struct OneState {
uint32 matchcond; // conditions to match right now.
- uint32 action[1];
+ uint32 action[];
};
// The uint32 conditions in the action are a combination of
@@ -385,7 +385,7 @@ bool Prog::IsOnePass() {
// Limit max node count to 65000 as a conservative estimate to
// avoid overflowing 16-bit node index in encoding.
int maxnodes = 2 + inst_count(kInstByteRange);
- int statesize = sizeof(OneState) + (bytemap_range_-1)*sizeof(uint32);
+ int statesize = sizeof(OneState) + bytemap_range_*sizeof(uint32);
if (maxnodes >= 65000 || dfa_mem_ / 4 / statesize < maxnodes)
return false;
diff --git a/re2/re2.h b/re2/re2.h
index 56fde7f..d9139b2 100644
--- a/re2/re2.h
+++ b/re2/re2.h
@@ -340,6 +340,11 @@ class RE2 {
#ifndef SWIG
private:
+ template <typename F, typename SP>
+ static inline bool Apply(F f, SP sp, const RE2& re) {
+ return f(sp, re, NULL, 0);
+ }
+
template <typename F, typename SP, typename... A>
static inline bool Apply(F f, SP sp, const RE2& re, const A&... a) {
const Arg* const args[] = {&a...};