From d7c8ffc7fdafd16d92cc6b5696a32a540237d7e6 Mon Sep 17 00:00:00 2001 From: Justin Viiret Date: Thu, 14 Jan 2016 09:53:15 +1100 Subject: [PATCH] Use correct type for anchored matcher build --- src/rose/rose_build_anchored.cpp | 23 +++++++++++------------ src/rose/rose_build_anchored.h | 10 ++++++---- src/rose/rose_build_bytecode.cpp | 2 +- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/rose/rose_build_anchored.cpp b/src/rose/rose_build_anchored.cpp index 675f8c68..ef0026d4 100644 --- a/src/rose/rose_build_anchored.cpp +++ b/src/rose/rose_build_anchored.cpp @@ -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 &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> &anchored_dfas, return total_size; } -aligned_unique_ptr buildAnchoredAutomataMatcher(RoseBuildImpl &tbi, - size_t *asize) { - const CompileContext &cc = tbi.cc; - remapAnchoredReports(tbi); +aligned_unique_ptr +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> anchored_dfas; - getAnchoredDfas(tbi, &anchored_dfas); + getAnchoredDfas(build, &anchored_dfas); - mergeAnchoredDfas(anchored_dfas, tbi); + mergeAnchoredDfas(anchored_dfas, build); vector> nfas; vector start_offset; // start offset for each dfa (dots removed) @@ -837,7 +836,7 @@ aligned_unique_ptr buildAnchoredAutomataMatcher(RoseBuildImpl &tbi, } *asize = total_size; - aligned_unique_ptr atable = aligned_zmalloc_unique(total_size); + auto atable = aligned_zmalloc_unique(total_size); char *curr = (char *)atable.get(); u32 state_offset = 0; diff --git a/src/rose/rose_build_anchored.h b/src/rose/rose_build_anchored.h index 1ee8be74..3ccd8cfb 100644 --- a/src/rose/rose_build_anchored.h +++ b/src/rose/rose_build_anchored.h @@ -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 #include +struct anchored_matcher_info; struct RoseEngine; namespace ue2 { @@ -46,9 +47,10 @@ class NGHolder; class RoseBuildImpl; struct Grey; -aligned_unique_ptr buildAnchoredAutomataMatcher(RoseBuildImpl &tbi, - size_t *asize); -u32 anchoredStateSize(const void *atable); +aligned_unique_ptr +buildAnchoredAutomataMatcher(RoseBuildImpl &build, size_t *asize); + +u32 anchoredStateSize(const anchored_matcher_info *atable); bool anchoredIsMulti(const RoseEngine &engine); #define ANCHORED_FAIL 0 diff --git a/src/rose/rose_build_bytecode.cpp b/src/rose/rose_build_bytecode.cpp index 9444005d..910f320b 100644 --- a/src/rose/rose_build_bytecode.cpp +++ b/src/rose/rose_build_bytecode.cpp @@ -4028,7 +4028,7 @@ aligned_unique_ptr RoseBuildImpl::buildFinalEngine(u32 minWidth) { size_t floatingStreamStateRequired = 0; size_t historyRequired = calcHistoryRequired(); // Updated by HWLM. - aligned_unique_ptr atable = + aligned_unique_ptr atable = buildAnchoredAutomataMatcher(*this, &asize); aligned_unique_ptr ftable = buildFloatingMatcher( *this, &fsize, &historyRequired, &floatingStreamStateRequired);