mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
fdr: reduce confirm size to a u8
Also removes the flexible array member from the LitInfo structure.
This commit is contained in:
parent
98c791dc6e
commit
f7cc8a618d
@ -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:
|
||||
@ -52,19 +52,18 @@ typedef enum LitInfoFlags {
|
||||
/**
|
||||
* \brief Structure describing a literal, linked to by FDRConfirm.
|
||||
*
|
||||
* This structure is followed in memory by a variable-sized string prefix at
|
||||
* LitInfo::s, for strings that are longer than CONF_TYPE.
|
||||
* This structure is followed in memory by a variable-sized string prefix, for
|
||||
* strings that are longer than CONF_TYPE.
|
||||
*/
|
||||
struct LitInfo {
|
||||
CONF_TYPE v;
|
||||
CONF_TYPE msk;
|
||||
hwlm_group_t groups;
|
||||
u32 size;
|
||||
u32 id; // literal ID as passed in
|
||||
u8 size;
|
||||
u8 flags; /* LitInfoFlags */
|
||||
u8 next;
|
||||
u8 extended_size;
|
||||
u8 s[1]; // literal prefix, which continues "beyond" this struct.
|
||||
};
|
||||
|
||||
#define FDRC_FLAG_NO_CONFIRM 1
|
||||
|
@ -107,7 +107,7 @@ void fillLitInfo(const vector<hwlmLiteral> &lits, vector<LitInfo> &tmpLitInfo,
|
||||
info.extended_size = verify_u8(lit.msk.size());
|
||||
}
|
||||
info.flags = flags;
|
||||
info.size = verify_u32(lit.s.size());
|
||||
info.size = verify_u8(lit.s.size());
|
||||
info.groups = lit.groups;
|
||||
|
||||
// these are built up assuming a LE machine
|
||||
@ -333,8 +333,8 @@ getFDRConfirm(const vector<hwlmLiteral> &lits, bool applyOneCharOpt,
|
||||
const string &t = lits[litIdx].s;
|
||||
if (t.size() > sizeof(CONF_TYPE)) {
|
||||
size_t prefix_len = t.size() - sizeof(CONF_TYPE);
|
||||
memcpy(&finalLI.s[0], t.c_str(), prefix_len);
|
||||
ptr = &finalLI.s[0] + prefix_len;
|
||||
memcpy(ptr, t.c_str(), prefix_len);
|
||||
ptr += prefix_len;
|
||||
}
|
||||
|
||||
ptr = ROUNDUP_PTR(ptr, alignof(LitInfo));
|
||||
|
@ -86,7 +86,7 @@ void confWithBit(const struct FDRConfirm *fdrc, const struct FDR_Runtime_Args *a
|
||||
// as for the regular case, no need to do a full confirm if
|
||||
// we're a short literal
|
||||
if (unlikely(li->size > sizeof(CONF_TYPE))) {
|
||||
const u8 *s1 = li->s;
|
||||
const u8 *s1 = (const u8 *)li + sizeof(*li);
|
||||
const u8 *s2 = s1 + full_overhang;
|
||||
const u8 *loc1 = history + len_history - full_overhang;
|
||||
const u8 *loc2 = buf;
|
||||
@ -106,7 +106,8 @@ void confWithBit(const struct FDRConfirm *fdrc, const struct FDR_Runtime_Args *a
|
||||
|
||||
// if string < conf_type we don't need regular string cmp
|
||||
if (unlikely(li->size > sizeof(CONF_TYPE))) {
|
||||
if (cmpForward(loc, li->s, li->size - sizeof(CONF_TYPE),
|
||||
const u8 *s = (const u8 *)li + sizeof(*li);
|
||||
if (cmpForward(loc, s, li->size - sizeof(CONF_TYPE),
|
||||
caseless)) {
|
||||
goto out;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user