]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
Provide access to scratch in queues
authorAlex Coyte <a.coyte@intel.com>
Tue, 31 May 2016 04:46:09 +0000 (14:46 +1000)
committerMatthew Barr <matthew.barr@intel.com>
Fri, 8 Jul 2016 00:46:50 +0000 (10:46 +1000)
This largely reverts commit f8ecf33236b0695d9539e8e34cf0bb0467614cdf.

src/nfa/nfa_api_queue.h
src/scratch.c
unit/internal/lbr.cpp
unit/internal/limex_nfa.cpp

index 1373425d84f1bd1e6c2999f07d3922a4f772fbcf..59c18fcaefee022c7f2dc3e8933a2149ba33e332 100644 (file)
@@ -91,6 +91,7 @@ struct mq {
                         * history buffer; (logically) immediately before the
                         * main buffer */
     size_t hlength; /**< length of the history buffer */
+    struct hs_scratch *scratch; /**< global scratch space */
     char report_current; /**<
                           * report_current matches at starting offset through
                           * callback. If true, the queue must be located at a
index d8742e7dd474a076fba9fd8280f8ce1de0a983a4..dae2c672e4469a14f883c11c46aa0238bb60cbc2 100644 (file)
@@ -227,6 +227,11 @@ hs_error_t alloc_scratch(const hs_scratch_t *proto, hs_scratch_t **scratch) {
     // Don't get too big for your boots
     assert((size_t)(current - (char *)s) <= alloc_size);
 
+    // Init q->scratch ptr for every queue.
+    for (struct mq *qi = s->queues; qi != s->queues + queueCount; ++qi) {
+        qi->scratch = s;
+    }
+
     return HS_SUCCESS;
 }
 
index 2bb359df9c53be68dbde2aa518d523a3b23ce6ea..f335e184a5f8a127cbf5bf24ef4111c33df93d6e 100644 (file)
@@ -122,6 +122,7 @@ protected:
         q.length = 0; // filled in by test
         q.history = nullptr;
         q.hlength = 0;
+        q.scratch = nullptr; // not needed by LBR
         q.report_current = 0;
         q.cb = onMatch;
         q.som_cb = nullptr; // only used by Haig
index 91ab09dbd0940641b7485eb7e00a95c93d71897e..9d3c00b5e6689f3a7df4f9e3589d84c2a5d79773 100644 (file)
@@ -102,6 +102,7 @@ protected:
         q.length = SCAN_DATA.size();
         q.history = nullptr;
         q.hlength = 0;
+        q.scratch = nullptr; /* limex does not use scratch */
         q.report_current = 0;
         q.cb = onMatch;
         q.som_cb = nullptr; // only used by Haig
@@ -396,6 +397,7 @@ protected:
         q.length = ZOMBIE_SCAN_DATA.length();
         q.history = nullptr;
         q.hlength = 0;
+        q.scratch = nullptr; /* limex does not use scratch */
         q.report_current = 0;
         q.cb = onMatch;
         q.som_cb = nullptr; // only used by Haig