]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
Use correct type for anchored matcher build
authorJustin Viiret <justin.viiret@intel.com>
Wed, 13 Jan 2016 22:53:15 +0000 (09:53 +1100)
committerMatthew Barr <matthew.barr@intel.com>
Tue, 1 Mar 2016 00:24:09 +0000 (11:24 +1100)
src/rose/rose_build_anchored.cpp
src/rose/rose_build_anchored.h
src/rose/rose_build_bytecode.cpp

index 675f8c68ca03ed71f65c617f251ae7e8035b987c..ef0026d43b21d7a10c3a62a42916c9298db8c5da 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Intel Corporation
+ * Copyright (c) 2015-2016, Intel Corporation
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -217,13 +217,12 @@ void populate_holder(const simple_anchored_info &sai, const set<u32> &exit_ids,
     h[v].reports.insert(exit_ids.begin(), exit_ids.end());
 }
 
-u32 anchoredStateSize(const void *atable) {
+u32 anchoredStateSize(const anchored_matcher_info *atable) {
     if (!atable) {
         return 0;
     }
 
-    const struct anchored_matcher_info *curr
-        = (const anchored_matcher_info *)atable;
+    const struct anchored_matcher_info *curr = atable;
 
     // Walk the list until we find the last element; total state size will be
     // that engine's state offset plus its state requirement.
@@ -812,21 +811,21 @@ size_t buildNfas(vector<unique_ptr<raw_dfa>> &anchored_dfas,
     return total_size;
 }
 
-aligned_unique_ptr<void> buildAnchoredAutomataMatcher(RoseBuildImpl &tbi,
-                                                      size_t *asize) {
-    const CompileContext &cc = tbi.cc;
-    remapAnchoredReports(tbi);
+aligned_unique_ptr<anchored_matcher_info>
+buildAnchoredAutomataMatcher(RoseBuildImpl &build, size_t *asize) {
+    const CompileContext &cc = build.cc;
+    remapAnchoredReports(build);
 
-    if (tbi.anchored_nfas.empty() && tbi.anchored_simple.empty()) {
+    if (build.anchored_nfas.empty() && build.anchored_simple.empty()) {
         DEBUG_PRINTF("empty\n");
         *asize = 0;
         return nullptr;
     }
 
     vector<unique_ptr<raw_dfa>> anchored_dfas;
-    getAnchoredDfas(tbi, &anchored_dfas);
+    getAnchoredDfas(build, &anchored_dfas);
 
-    mergeAnchoredDfas(anchored_dfas, tbi);
+    mergeAnchoredDfas(anchored_dfas, build);
 
     vector<aligned_unique_ptr<NFA>> nfas;
     vector<u32> start_offset; // start offset for each dfa (dots removed)
@@ -837,7 +836,7 @@ aligned_unique_ptr<void> buildAnchoredAutomataMatcher(RoseBuildImpl &tbi,
     }
 
     *asize = total_size;
-    aligned_unique_ptr<void> atable = aligned_zmalloc_unique<void>(total_size);
+    auto atable = aligned_zmalloc_unique<anchored_matcher_info>(total_size);
     char *curr = (char *)atable.get();
 
     u32 state_offset = 0;
index 1ee8be74f77ea6194aecbfd1c4d903b283bce487..3ccd8cfb74ce02751d6e14ff88f9d867f3e76986 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Intel Corporation
+ * Copyright (c) 2015-2016, Intel Corporation
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -38,6 +38,7 @@
 #include <vector>
 #include <set>
 
+struct anchored_matcher_info;
 struct RoseEngine;
 
 namespace ue2 {
@@ -46,9 +47,10 @@ class NGHolder;
 class RoseBuildImpl;
 struct Grey;
 
-aligned_unique_ptr<void> buildAnchoredAutomataMatcher(RoseBuildImpl &tbi,
-                                                      size_t *asize);
-u32 anchoredStateSize(const void *atable);
+aligned_unique_ptr<anchored_matcher_info>
+buildAnchoredAutomataMatcher(RoseBuildImpl &build, size_t *asize);
+
+u32 anchoredStateSize(const anchored_matcher_info *atable);
 bool anchoredIsMulti(const RoseEngine &engine);
 
 #define ANCHORED_FAIL    0
index 9444005da78c176f8b661d5500b12c923b26b257..910f320bb88c8c36c4c0e7bd628e8008c775cc95 100644 (file)
@@ -4028,7 +4028,7 @@ aligned_unique_ptr<RoseEngine> RoseBuildImpl::buildFinalEngine(u32 minWidth) {
     size_t floatingStreamStateRequired = 0;
     size_t historyRequired = calcHistoryRequired(); // Updated by HWLM.
 
-    aligned_unique_ptr<void> atable =
+    aligned_unique_ptr<anchored_matcher_info> atable =
         buildAnchoredAutomataMatcher(*this, &asize);
     aligned_unique_ptr<HWLM> ftable = buildFloatingMatcher(
         *this, &fsize, &historyRequired, &floatingStreamStateRequired);