auto confirmTmp = setupFullConfs(lits, eng, bucketToLits, make_small);
assert(ISALIGNED_16(tabSize));
- assert(ISALIGNED_16(confirmTmp.second));
- assert(ISALIGNED_16(floodControlTmp.second));
+ assert(ISALIGNED_16(confirmTmp.size()));
+ assert(ISALIGNED_16(floodControlTmp.size()));
size_t headerSize = ROUNDUP_16(sizeof(FDR));
- size_t size = ROUNDUP_16(headerSize + tabSize + confirmTmp.second +
- floodControlTmp.second);
+ size_t size = ROUNDUP_16(headerSize + tabSize + confirmTmp.size() +
+ floodControlTmp.size());
DEBUG_PRINTF("sizes base=%zu tabSize=%zu confirm=%zu floodControl=%zu "
"total=%zu\n",
- headerSize, tabSize, confirmTmp.second, floodControlTmp.second,
+ headerSize, tabSize, confirmTmp.size(), floodControlTmp.size(),
size);
- aligned_unique_ptr<FDR> fdr = aligned_zmalloc_unique<FDR>(size);
+ auto fdr = aligned_zmalloc_unique<FDR>(size);
assert(fdr); // otherwise would have thrown std::bad_alloc
fdr->size = size;
createInitialState(fdr.get());
u8 *fdr_base = (u8 *)fdr.get();
- u8 * ptr = fdr_base + ROUNDUP_16(sizeof(FDR));
+ u8 *ptr = fdr_base + ROUNDUP_16(sizeof(FDR));
copy(tab.begin(), tab.end(), ptr);
ptr += tabSize;
- memcpy(ptr, confirmTmp.first.get(), confirmTmp.second);
- ptr += confirmTmp.second;
+ memcpy(ptr, confirmTmp.get(), confirmTmp.size());
+ ptr += confirmTmp.size();
fdr->floodOffset = verify_u32(ptr - fdr_base);
- memcpy(ptr, floodControlTmp.first.get(), floodControlTmp.second);
- ptr += floodControlTmp.second;
+ memcpy(ptr, floodControlTmp.get(), floodControlTmp.size());
+ ptr += floodControlTmp.size();
/* we are allowing domains 9 to 15 only */
assert(eng.bits > 8 && eng.bits < 16);
#include "ue2common.h"
#include "hwlm/hwlm_literal.h"
-#include "util/alloc.h"
+#include "util/bytecode_ptr.h"
#include <map>
#include <utility>
struct hwlmStreamingControl;
struct Grey;
-std::pair<aligned_unique_ptr<u8>, size_t> setupFullConfs(
- const std::vector<hwlmLiteral> &lits, const EngineDescription &eng,
- std::map<BucketIndex, std::vector<LiteralIndex>> &bucketToLits,
- bool make_small);
+bytecode_ptr<u8> setupFullConfs(const std::vector<hwlmLiteral> &lits,
+ const EngineDescription &eng,
+ std::map<BucketIndex, std::vector<LiteralIndex>> &bucketToLits,
+ bool make_small);
// all suffixes include an implicit max_bucket_width suffix to ensure that
// we always read a full-scale flood "behind" us in terms of what's in our
// state; if we don't have a flood that's long enough we won't be in the
// right state yet to allow blindly advancing
-std::pair<aligned_unique_ptr<u8>, size_t>
-setupFDRFloodControl(const std::vector<hwlmLiteral> &lits,
- const EngineDescription &eng, const Grey &grey);
+bytecode_ptr<u8> setupFDRFloodControl(const std::vector<hwlmLiteral> &lits,
+ const EngineDescription &eng,
+ const Grey &grey);
-std::pair<aligned_unique_ptr<u8>, size_t>
+bytecode_ptr<u8>
fdrBuildTableStreaming(const std::vector<hwlmLiteral> &lits,
hwlmStreamingControl &stream_control);
return {move(fdrc), actual_size};
}
-pair<aligned_unique_ptr<u8>, size_t>
+bytecode_ptr<u8>
setupFullConfs(const vector<hwlmLiteral> &lits,
const EngineDescription &eng,
map<BucketIndex, vector<LiteralIndex>> &bucketToLits,
u32 totalConfSwitchSize = nBuckets * sizeof(u32);
u32 totalSize = ROUNDUP_16(totalConfSwitchSize + totalConfirmSize);
- auto buf = aligned_zmalloc_unique<u8>(totalSize);
+ auto buf = make_bytecode_ptr<u8>(totalSize, 16);
assert(buf); // otherwise would have thrown std::bad_alloc
u32 *confBase = (u32 *)buf.get();
ptr += p.second;
confBase[idx] = confirm_offset;
}
- return {move(buf), totalSize};
+
+ return buf;
}
} // namespace ue2
}
}
-pair<aligned_unique_ptr<u8>, size_t>
-setupFDRFloodControl(const vector<hwlmLiteral> &lits,
- const EngineDescription &eng, const Grey &grey) {
+bytecode_ptr<u8> setupFDRFloodControl(const vector<hwlmLiteral> &lits,
+ const EngineDescription &eng,
+ const Grey &grey) {
vector<FDRFlood> tmpFlood(N_CHARS);
u32 default_suffix = eng.getDefaultFloodSuffixLength();
size_t floodStructSize = sizeof(FDRFlood) * nDistinctFloods;
size_t totalSize = ROUNDUP_16(floodHeaderSize + floodStructSize);
- auto buf = aligned_zmalloc_unique<u8>(totalSize);
+ auto buf = make_bytecode_ptr<u8>(totalSize, 16);
assert(buf); // otherwise would have thrown std::bad_alloc
u32 *floodHeader = (u32 *)buf.get();
DEBUG_PRINTF("made a flood structure with %zu + %zu = %zu\n",
floodHeaderSize, floodStructSize, totalSize);
- return {move(buf), totalSize};
+ return buf;
}
} // namespace ue2
size_t size = ROUNDUP_N(sizeof(Teddy) +
maskLen +
- confirmTmp.second +
- floodControlTmp.second,
+ confirmTmp.size() +
+ floodControlTmp.size(),
16 * maskWidth);
- aligned_unique_ptr<FDR> fdr = aligned_zmalloc_unique<FDR>(size);
+ auto fdr = aligned_zmalloc_unique<FDR>(size);
assert(fdr); // otherwise would have thrown std::bad_alloc
Teddy *teddy = (Teddy *)fdr.get(); // ugly
u8 *teddy_base = (u8 *)teddy;
teddy->maxStringLen = verify_u32(maxLen(lits));
u8 *ptr = teddy_base + sizeof(Teddy) + maskLen;
- memcpy(ptr, confirmTmp.first.get(), confirmTmp.second);
- ptr += confirmTmp.second;
+ memcpy(ptr, confirmTmp.get(), confirmTmp.size());
+ ptr += confirmTmp.size();
teddy->floodOffset = verify_u32(ptr - teddy_base);
- memcpy(ptr, floodControlTmp.first.get(), floodControlTmp.second);
- ptr += floodControlTmp.second;
+ memcpy(ptr, floodControlTmp.get(), floodControlTmp.size());
+ ptr += floodControlTmp.size();
u8 *baseMsk = teddy_base + sizeof(Teddy);