fix selected warnings from cppcheck

Fixes issue 2.

R=r
CC=re2-dev
http://codereview.appspot.com/665041
diff --git a/re2/compile.cc b/re2/compile.cc
index 5bab033..8f6ef36 100644
--- a/re2/compile.cc
+++ b/re2/compile.cc
@@ -205,8 +205,7 @@
 }
 
 Compiler::~Compiler() {
-  if (prog_)
-    delete prog_;
+  delete prog_;
 }
 
 bool Compiler::CanAllocInst() {
diff --git a/re2/dfa.cc b/re2/dfa.cc
index 7730484..9b1968d 100644
--- a/re2/dfa.cc
+++ b/re2/dfa.cc
@@ -56,7 +56,7 @@
  public:
   DFA(Prog* prog, Prog::MatchKind kind, int64 max_mem);
   ~DFA();
-  bool ok() { return !init_failed_; }
+  bool ok() const { return !init_failed_; }
   Prog::MatchKind kind() { return kind_; }
 
   // Searches for the regular expression in text, which is considered
@@ -94,7 +94,7 @@
   // States, linked by the next_ pointers.  If in state s and reading
   // byte c, the next state should be s->next_[c].
   struct State {
-    inline bool IsMatch() { return flag_ & kFlagMatch; }
+    inline bool IsMatch() const { return flag_ & kFlagMatch; }
     Inst** inst_;       // Instruction pointers in the state.
     int ninst_;         // # of inst_ pointers.
     uint flag_;         // Empty string bitfield flags in effect on the way
@@ -393,9 +393,6 @@
     SparseArray<Inst*>::set_new(id, inst);
   }
 
-  void set_last_was_mark(bool b) { last_was_mark_ = b; }
-  bool last_was_mark() { return last_was_mark_; }
-
  private:
   int n_;                // size excluding marks
   int maxmark_;          // maximum number of marks
@@ -696,7 +693,7 @@
     mutex_.AssertHeld();
 
   // Look in the cache for a pre-existing state.
-  State state = { inst, ninst, flag };
+  State state = { inst, ninst, flag, NULL };
   StateSet::iterator it = state_cache_.find(&state);
   if (it != state_cache_.end()) {
     if (DebugDFA)
diff --git a/re2/nfa.cc b/re2/nfa.cc
index 243f0d6..c0d6ffc 100644
--- a/re2/nfa.cc
+++ b/re2/nfa.cc
@@ -68,9 +68,9 @@
     int j;
 
     AddState()
-      : ip(NULL), j(-1) {}
+      : ip(NULL), cap_j(NULL), j(-1) {}
     explicit AddState(Inst* ip)
-      : ip(ip), j(-1) {}
+      : ip(ip), cap_j(NULL), j(-1) {}
     AddState(Inst* ip, const char* cap_j, int j)
       : ip(ip), cap_j(cap_j), j(j) {}
   };
diff --git a/re2/prefilter.cc b/re2/prefilter.cc
index cc2eca4..93aea42 100644
--- a/re2/prefilter.cc
+++ b/re2/prefilter.cc
@@ -159,7 +159,7 @@
 Prefilter* Prefilter::OrStrings(set<string>* ss) {
   SimplifyStringSet(ss);
   Prefilter* or_prefilter = NULL;
-  if (ss->size() != 0) {
+  if (!ss->empty()) {
     or_prefilter = new Prefilter(NONE);
     for (SSIter i = ss->begin(); i != ss->end(); ++i)
       or_prefilter = Or(or_prefilter, FromString(*i));
diff --git a/re2/re2.cc b/re2/re2.cc
index 50e71e0..8f96f83 100644
--- a/re2/re2.cc
+++ b/re2/re2.cc
@@ -207,12 +207,9 @@
     suffix_regexp_->Decref();
   if (entire_regexp_)
     entire_regexp_->Decref();
-  if (mutex_)
-    delete mutex_;
-  if (prog_)
-    delete prog_;
-  if (rprog_)
-    delete rprog_;
+  delete mutex_;
+  delete prog_;
+  delete rprog_;
   if (error_ != &empty_string)
     delete error_;
   if (named_groups_ != NULL && named_groups_ != &empty_map)
diff --git a/re2/testing/backtrack.cc b/re2/testing/backtrack.cc
index b9dcbd2..af02eac 100644
--- a/re2/testing/backtrack.cc
+++ b/re2/testing/backtrack.cc
@@ -79,6 +79,7 @@
   : prog_(prog),
     anchored_(false),
     longest_(false),
+    endmatch_(false),
     submatch_(NULL),
     nsubmatch_(0),
     visited_(NULL),
@@ -120,8 +121,7 @@
 
   // Allocate new visited_ bitmap -- size is proportional
   // to text, so have to reallocate on each call to Search.
-  if (visited_)
-    delete[] visited_;
+  delete[] visited_;
   nvisited_ = (prog_->size()*(text.size()+1) + 31)/32;
   visited_ = new uint32[nvisited_];
   memset(visited_, 0, nvisited_*sizeof visited_[0]);
diff --git a/re2/testing/string_generator.cc b/re2/testing/string_generator.cc
index 4fdcb38..5be6d3e 100644
--- a/re2/testing/string_generator.cc
+++ b/re2/testing/string_generator.cc
@@ -27,8 +27,7 @@
 }
 
 StringGenerator::~StringGenerator() {
-  if (acm_)
-    delete acm_;
+  delete acm_;
 }
 
 // Resets the string generator state to the beginning.
diff --git a/re2/testing/tester.cc b/re2/testing/tester.cc
index 6987be9..fc631c0 100644
--- a/re2/testing/tester.cc
+++ b/re2/testing/tester.cc
@@ -265,14 +265,10 @@
 TestInstance::~TestInstance() {
   if (regexp_)
     regexp_->Decref();
-  if (prog_)
-    delete prog_;
-  if (rprog_)
-    delete rprog_;
-  if (re_)
-    delete re_;
-  if (re2_)
-    delete re2_;
+  delete prog_;
+  delete rprog_;
+  delete re_;
+  delete re2_;
 }
 
 // Runs a single search using the named engine type.