hwlm: use bytecode_ptr for HWLM structures

This commit is contained in:
Justin Viiret
2017-04-03 13:56:49 +10:00
committed by Matthew Barr
parent 813f1e3fb9
commit 7b17d418e7
5 changed files with 52 additions and 71 deletions

View File

@@ -97,9 +97,9 @@ bool isNoodleable(const vector<hwlmLiteral> &lits,
return true;
}
aligned_unique_ptr<HWLM> hwlmBuild(const vector<hwlmLiteral> &lits,
bool make_small, const CompileContext &cc,
UNUSED hwlm_group_t expected_groups) {
bytecode_ptr<HWLM> hwlmBuild(const vector<hwlmLiteral> &lits, bool make_small,
const CompileContext &cc,
UNUSED hwlm_group_t expected_groups) {
assert(!lits.empty());
dumpLits(lits);
@@ -151,7 +151,7 @@ aligned_unique_ptr<HWLM> hwlmBuild(const vector<hwlmLiteral> &lits,
engType = HWLM_ENGINE_FDR;
auto fdr = fdrBuildTable(lits, make_small, cc.target_info, cc.grey);
if (fdr) {
engSize = fdrSize(fdr.get());
engSize = fdr.size();
}
eng = move(fdr);
}
@@ -165,7 +165,7 @@ aligned_unique_ptr<HWLM> hwlmBuild(const vector<hwlmLiteral> &lits,
throw ResourceLimitError();
}
auto h = aligned_zmalloc_unique<HWLM>(ROUNDUP_CL(sizeof(HWLM)) + engSize);
auto h = make_bytecode_ptr<HWLM>(ROUNDUP_CL(sizeof(HWLM)) + engSize, 64);
h->type = engType;
memcpy(HWLM_DATA(h.get()), eng.get(), engSize);

View File

@@ -35,7 +35,7 @@
#include "hwlm.h"
#include "ue2common.h"
#include "util/alloc.h"
#include "util/bytecode_ptr.h"
#include <memory>
#include <vector>
@@ -60,10 +60,9 @@ struct hwlmLiteral;
* may result in a nullptr return value, or a std::bad_alloc exception being
* thrown.
*/
aligned_unique_ptr<HWLM>
hwlmBuild(const std::vector<hwlmLiteral> &lits, bool make_small,
const CompileContext &cc,
hwlm_group_t expected_groups = HWLM_ALL_GROUPS);
bytecode_ptr<HWLM> hwlmBuild(const std::vector<hwlmLiteral> &lits,
bool make_small, const CompileContext &cc,
hwlm_group_t expected_groups = HWLM_ALL_GROUPS);
/**
* Returns an estimate of the number of repeated characters on the end of a