mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-09-29 19:24:25 +03:00
cStyleCasts
This commit is contained in:
@@ -68,7 +68,7 @@ void two_aligned_free(void *mem) {
|
||||
return;
|
||||
}
|
||||
// Allocated with two_aligned_malloc above.
|
||||
free((char *)mem - 2);
|
||||
free(static_cast<char *>(mem) - 2);
|
||||
}
|
||||
|
||||
TEST(CustomAllocator, TwoAlignedCompile) {
|
||||
|
@@ -58,14 +58,14 @@ TEST(ExtParam, LargeMinOffset) {
|
||||
// ensure it doesn't match.
|
||||
string corpus = "hatstand" + string(80000, '_') + "teakettle";
|
||||
err = hs_scan(db, corpus.c_str(), corpus.length(), 0, scratch, record_cb,
|
||||
(void *)&c);
|
||||
reinterpret_cast<void *>(&c));
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_EQ(0U, c.matches.size());
|
||||
|
||||
// Try exactly at the min_offset.
|
||||
corpus = "hatstand" + string(99983, '_') + "teakettle";
|
||||
err = hs_scan(db, corpus.c_str(), corpus.length(), 0, scratch, record_cb,
|
||||
(void *)&c);
|
||||
reinterpret_cast<void *>(&c));
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_EQ(1U, c.matches.size());
|
||||
ASSERT_EQ(MatchRecord(100000, 0), c.matches[0]);
|
||||
@@ -97,7 +97,7 @@ TEST(ExtParam, LargeExactOffset) {
|
||||
// ensure it doesn't match.
|
||||
string corpus = "hatstand" + string(199982, '_') + "teakettle";
|
||||
err = hs_scan(db, corpus.c_str(), corpus.length(), 0, scratch, record_cb,
|
||||
(void *)&c);
|
||||
reinterpret_cast<void *>(&c));
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_EQ(0U, c.matches.size());
|
||||
|
||||
@@ -113,7 +113,7 @@ TEST(ExtParam, LargeExactOffset) {
|
||||
c.clear();
|
||||
corpus = "hatstand" + string(199984, '_') + "teakettle";
|
||||
err = hs_scan(db, corpus.c_str(), corpus.length(), 0, scratch, record_cb,
|
||||
(void *)&c);
|
||||
reinterpret_cast<void *>(&c));
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_EQ(0U, c.matches.size());
|
||||
|
||||
@@ -143,14 +143,14 @@ TEST(ExtParam, LargeMinLength) {
|
||||
// short.
|
||||
string corpus = string(10000, '_') + "hatstand" + string(80000, '_') + "teakettle";
|
||||
err = hs_scan(db, corpus.c_str(), corpus.length(), 0, scratch, record_cb,
|
||||
(void *)&c);
|
||||
reinterpret_cast<void *>(&c));
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_EQ(0U, c.matches.size());
|
||||
|
||||
// Now, a match of the right length.
|
||||
corpus = string(10000, '_') + "hatstand" + string(99983, '_') + "teakettle";
|
||||
err = hs_scan(db, corpus.c_str(), corpus.length(), 0, scratch, record_cb,
|
||||
(void *)&c);
|
||||
reinterpret_cast<void *>(&c));
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_EQ(1U, c.matches.size());
|
||||
ASSERT_EQ(MatchRecord(110000, 0), c.matches[0]);
|
||||
|
@@ -87,7 +87,7 @@ protected:
|
||||
static
|
||||
int count_cb(unsigned, unsigned long long, unsigned long long, unsigned,
|
||||
void *ctxt) {
|
||||
size_t *count = (size_t *)ctxt;
|
||||
size_t *count = static_cast<size_t *>(ctxt);
|
||||
(*count)++;
|
||||
return 0;
|
||||
}
|
||||
|
@@ -60,7 +60,7 @@ TEST(LogicalCombination, SingleComb1) {
|
||||
|
||||
c.halt = 0;
|
||||
err = hs_scan(db, data.c_str(), data.size(), 0, scratch, record_cb,
|
||||
(void *)&c);
|
||||
reinterpret_cast<void *>(&c));
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_EQ(16U, c.matches.size());
|
||||
ASSERT_EQ(MatchRecord(3, 101), c.matches[0]);
|
||||
@@ -108,7 +108,7 @@ TEST(LogicalCombination, SingleCombQuietSub1) {
|
||||
|
||||
c.halt = 0;
|
||||
err = hs_scan(db, data.c_str(), data.size(), 0, scratch, record_cb,
|
||||
(void *)&c);
|
||||
reinterpret_cast<void *>(&c));
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_EQ(8U, c.matches.size());
|
||||
ASSERT_EQ(MatchRecord(18, 1001), c.matches[0]);
|
||||
@@ -151,7 +151,7 @@ TEST(LogicalCombination, MultiCombQuietSub1) {
|
||||
|
||||
c.halt = 0;
|
||||
err = hs_scan(db, data.c_str(), data.size(), 0, scratch, record_cb,
|
||||
(void *)&c);
|
||||
reinterpret_cast<void *>(&c));
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_EQ(10U, c.matches.size());
|
||||
ASSERT_EQ(MatchRecord(3, 1003), c.matches[0]);
|
||||
@@ -198,7 +198,7 @@ TEST(LogicalCombination, MultiHighlanderCombQuietSub1) {
|
||||
|
||||
c.halt = 0;
|
||||
err = hs_scan(db, data.c_str(), data.size(), 0, scratch, record_cb,
|
||||
(void *)&c);
|
||||
reinterpret_cast<void *>(&c));
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_EQ(4U, c.matches.size());
|
||||
ASSERT_EQ(MatchRecord(3, 1003), c.matches[0]);
|
||||
@@ -237,7 +237,7 @@ TEST(LogicalCombination, MultiQuietCombQuietSub1) {
|
||||
|
||||
c.halt = 0;
|
||||
err = hs_scan(db, data.c_str(), data.size(), 0, scratch, record_cb,
|
||||
(void *)&c);
|
||||
reinterpret_cast<void *>(&c));
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_EQ(2U, c.matches.size());
|
||||
ASSERT_EQ(MatchRecord(3, 1003), c.matches[0]);
|
||||
@@ -270,7 +270,7 @@ TEST(LogicalCombination, SingleComb2) {
|
||||
|
||||
c.halt = 0;
|
||||
err = hs_scan(db, data.c_str(), data.size(), 0, scratch, record_cb,
|
||||
(void *)&c);
|
||||
reinterpret_cast<void *>(&c));
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_EQ(13U, c.matches.size());
|
||||
ASSERT_EQ(MatchRecord(6, 202), c.matches[0]);
|
||||
@@ -315,7 +315,7 @@ TEST(LogicalCombination, SingleCombQuietSub2) {
|
||||
|
||||
c.halt = 0;
|
||||
err = hs_scan(db, data.c_str(), data.size(), 0, scratch, record_cb,
|
||||
(void *)&c);
|
||||
reinterpret_cast<void *>(&c));
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_EQ(8U, c.matches.size());
|
||||
ASSERT_EQ(MatchRecord(18, 1002), c.matches[0]);
|
||||
@@ -354,7 +354,7 @@ TEST(LogicalCombination, SingleComb3) {
|
||||
|
||||
c.halt = 0;
|
||||
err = hs_scan(db, data.c_str(), data.size(), 0, scratch, record_cb,
|
||||
(void *)&c);
|
||||
reinterpret_cast<void *>(&c));
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_EQ(17U, c.matches.size());
|
||||
ASSERT_EQ(MatchRecord(3, 301), c.matches[0]);
|
||||
@@ -403,7 +403,7 @@ TEST(LogicalCombination, SingleCombQuietSub3) {
|
||||
|
||||
c.halt = 0;
|
||||
err = hs_scan(db, data.c_str(), data.size(), 0, scratch, record_cb,
|
||||
(void *)&c);
|
||||
reinterpret_cast<void *>(&c));
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_EQ(8U, c.matches.size());
|
||||
ASSERT_EQ(MatchRecord(23, 303), c.matches[0]);
|
||||
@@ -445,7 +445,7 @@ TEST(LogicalCombination, MultiCombDupSub4) {
|
||||
|
||||
c.halt = 0;
|
||||
err = hs_scan(db, data.c_str(), data.size(), 0, scratch, record_cb,
|
||||
(void *)&c);
|
||||
reinterpret_cast<void *>(&c));
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_EQ(23U, c.matches.size());
|
||||
ASSERT_EQ(MatchRecord(6, 202), c.matches[0]);
|
||||
@@ -503,7 +503,7 @@ TEST(LogicalCombination, MultiCombQuietDupSub4) {
|
||||
|
||||
c.halt = 0;
|
||||
err = hs_scan(db, data.c_str(), data.size(), 0, scratch, record_cb,
|
||||
(void *)&c);
|
||||
reinterpret_cast<void *>(&c));
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_EQ(17U, c.matches.size());
|
||||
ASSERT_EQ(MatchRecord(18, 1002), c.matches[0]);
|
||||
@@ -564,7 +564,7 @@ TEST(LogicalCombination, MultiCombUniSub5) {
|
||||
|
||||
c.halt = 0;
|
||||
err = hs_scan(db, data.c_str(), data.size(), 0, scratch, record_cb,
|
||||
(void *)&c);
|
||||
reinterpret_cast<void *>(&c));
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_EQ(46U, c.matches.size());
|
||||
ASSERT_EQ(MatchRecord(3, 101), c.matches[0]);
|
||||
@@ -656,7 +656,7 @@ TEST(LogicalCombination, MultiCombQuietUniSub5) {
|
||||
|
||||
c.halt = 0;
|
||||
err = hs_scan(db, data.c_str(), data.size(), 0, scratch, record_cb,
|
||||
(void *)&c);
|
||||
reinterpret_cast<void *>(&c));
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_EQ(30U, c.matches.size());
|
||||
ASSERT_EQ(MatchRecord(3, 101), c.matches[0]);
|
||||
@@ -717,7 +717,7 @@ TEST(LogicalCombination, SingleCombPurelyNegative6) {
|
||||
|
||||
c.halt = 0;
|
||||
err = hs_scan(db, data.c_str(), data.size(), 0, scratch, record_cb,
|
||||
(void *)&c);
|
||||
reinterpret_cast<void *>(&c));
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_EQ(1U, c.matches.size());
|
||||
ASSERT_EQ(MatchRecord(53, 1002), c.matches[0]);
|
||||
@@ -749,7 +749,7 @@ TEST(LogicalCombination, SingleCombQuietPurelyNegative6) {
|
||||
|
||||
c.halt = 0;
|
||||
err = hs_scan(db, data.c_str(), data.size(), 0, scratch, record_cb,
|
||||
(void *)&c);
|
||||
reinterpret_cast<void *>(&c));
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_EQ(0U, c.matches.size());
|
||||
|
||||
@@ -793,7 +793,7 @@ TEST(LogicalCombination, MultiCombPurelyNegativeUniSub6) {
|
||||
|
||||
c.halt = 0;
|
||||
err = hs_scan(db, data.c_str(), data.size(), 0, scratch, record_cb,
|
||||
(void *)&c);
|
||||
reinterpret_cast<void *>(&c));
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_EQ(3U, c.matches.size());
|
||||
ASSERT_EQ(MatchRecord(106, 202), c.matches[0]);
|
||||
@@ -841,7 +841,7 @@ TEST(LogicalCombination, MultiCombPurelyNegativeUniSubEOD6) {
|
||||
|
||||
c.halt = 0;
|
||||
err = hs_scan(db, data.c_str(), data.size(), 0, scratch, record_cb,
|
||||
(void *)&c);
|
||||
reinterpret_cast<void *>(&c));
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_EQ(8U, c.matches.size());
|
||||
ASSERT_EQ(MatchRecord(106, 102), c.matches[0]);
|
||||
@@ -897,7 +897,7 @@ TEST(LogicalCombination, MultiCombStream1) {
|
||||
int i;
|
||||
for (i = 0; i < 11; i++) {
|
||||
err = hs_scan_stream(stream, data[i].c_str(), data[i].size(), 0,
|
||||
scratch, record_cb, (void *)&c);
|
||||
scratch, record_cb, reinterpret_cast<void *>(&c));
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
}
|
||||
err = hs_close_stream(stream, scratch, dummy_cb, nullptr);
|
||||
|
@@ -59,7 +59,7 @@ TEST(MMAdaptor, norm_cont1) { // UE-901
|
||||
|
||||
c.halt = 0;
|
||||
err = hs_scan(db, data.c_str(), data.size(), 0, scratch, record_cb,
|
||||
(void *)&c);
|
||||
reinterpret_cast<void *>(&c));
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_EQ(3U, c.matches.size());
|
||||
ASSERT_EQ(MatchRecord(4, 30), c.matches[0]);
|
||||
@@ -92,7 +92,7 @@ TEST(MMAdaptor, norm_cont2) {
|
||||
|
||||
c.halt = 0;
|
||||
err = hs_scan(db, data.c_str(), data.size(), 0, scratch, record_cb,
|
||||
(void *)&c);
|
||||
reinterpret_cast<void *>(&c));
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_EQ(3U, c.matches.size());
|
||||
ASSERT_TRUE(c.matches.end() != find(c.matches.begin(), c.matches.end(), MatchRecord(20, 30)));
|
||||
@@ -125,7 +125,7 @@ TEST(MMAdaptor, norm_halt1) {
|
||||
|
||||
c.halt = 1;
|
||||
err = hs_scan(db, data.c_str(), data.size(), 0, scratch, record_cb,
|
||||
(void *)&c);
|
||||
reinterpret_cast<void *>(&c));
|
||||
ASSERT_EQ(HS_SCAN_TERMINATED, err);
|
||||
ASSERT_EQ(1U, c.matches.size());
|
||||
ASSERT_EQ(MatchRecord(4, 30), c.matches[0]);
|
||||
@@ -156,7 +156,7 @@ TEST(MMAdaptor, norm_halt2) { // UE-901
|
||||
|
||||
c.halt = 1;
|
||||
err = hs_scan(db, data.c_str(), data.size(), 0, scratch, record_cb,
|
||||
(void *)&c);
|
||||
reinterpret_cast<void *>(&c));
|
||||
ASSERT_EQ(HS_SCAN_TERMINATED, err);
|
||||
ASSERT_EQ(1U, c.matches.size());
|
||||
ASSERT_EQ(MatchRecord(20, 30), c.matches[0]);
|
||||
@@ -187,7 +187,7 @@ TEST(MMAdaptor, high_cont1) { // UE-901
|
||||
|
||||
c.halt = 0;
|
||||
err = hs_scan(db, data.c_str(), data.size(), 0, scratch, record_cb,
|
||||
(void *)&c);
|
||||
reinterpret_cast<void *>(&c));
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_EQ(2U, c.matches.size());
|
||||
ASSERT_TRUE(c.matches.end() != find(c.matches.begin(), c.matches.end(), MatchRecord(4, 30)));
|
||||
@@ -219,7 +219,7 @@ TEST(MMAdaptor, high_cont2) {
|
||||
|
||||
c.halt = 0;
|
||||
err = hs_scan(db, data.c_str(), data.size(), 0, scratch, record_cb,
|
||||
(void *)&c);
|
||||
reinterpret_cast<void *>(&c));
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_EQ(2U, c.matches.size());
|
||||
ASSERT_TRUE(c.matches.end() != find(c.matches.begin(), c.matches.end(), MatchRecord(20, 30)));
|
||||
@@ -251,7 +251,7 @@ TEST(MMAdaptor, high_halt1) {
|
||||
|
||||
c.halt = 1;
|
||||
err = hs_scan(db, data.c_str(), data.size(), 0, scratch, record_cb,
|
||||
(void *)&c);
|
||||
reinterpret_cast<void *>(&c));
|
||||
ASSERT_EQ(HS_SCAN_TERMINATED, err);
|
||||
ASSERT_EQ(1U, c.matches.size());
|
||||
ASSERT_EQ(MatchRecord(4, 30), c.matches[0]);
|
||||
@@ -282,7 +282,7 @@ TEST(MMAdaptor, high_halt2) {
|
||||
|
||||
c.halt = 1;
|
||||
err = hs_scan(db, data.c_str(), data.size(), 0, scratch, record_cb,
|
||||
(void *)&c);
|
||||
reinterpret_cast<void *>(&c));
|
||||
ASSERT_EQ(HS_SCAN_TERMINATED, err);
|
||||
ASSERT_EQ(1U, c.matches.size());
|
||||
ASSERT_TRUE(MatchRecord(20, 30) == c.matches[0]
|
||||
@@ -311,7 +311,7 @@ TEST(MPV, UE_2395) {
|
||||
|
||||
CallBackContext c;
|
||||
err = hs_scan(db, data.data(), data.size(), 0, scratch, record_cb,
|
||||
(void *)&c);
|
||||
reinterpret_cast<void *>(&c));
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
|
||||
unsigned seen = 39;
|
||||
@@ -358,7 +358,7 @@ TEST(MMRoseLiteralPath, issue_141) {
|
||||
|
||||
c.halt = 0;
|
||||
err = hs_scan(db, data.c_str(), data.size(), 0, scratch, record_cb,
|
||||
(void *)&c);
|
||||
reinterpret_cast<void *>(&c));
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_EQ(1U, c.matches.size());
|
||||
ASSERT_EQ(MatchRecord(19, 0), c.matches[0]);
|
||||
|
@@ -148,7 +148,7 @@ void runVectoredTest(match_event_handler cb_func) {
|
||||
static
|
||||
int rescan_block_cb(unsigned, unsigned long long, unsigned long long, unsigned,
|
||||
void *ctx) {
|
||||
RescanContext *rctx = (RescanContext *)ctx;
|
||||
RescanContext *rctx = reinterpret_cast<RescanContext *>(ctx);
|
||||
rctx->matches++;
|
||||
|
||||
const string data = "___foo___bar_";
|
||||
@@ -168,7 +168,7 @@ TEST(ScratchInUse, Block) {
|
||||
static
|
||||
int rescan_stream_cb(unsigned, unsigned long long, unsigned long long, unsigned,
|
||||
void *ctx) {
|
||||
RescanContext *rctx = (RescanContext *)ctx;
|
||||
RescanContext *rctx = reinterpret_cast<RescanContext *>(ctx);
|
||||
rctx->matches++;
|
||||
|
||||
const string data = "___foo___bar_";
|
||||
@@ -197,7 +197,7 @@ TEST(ScratchInUse, Streaming) {
|
||||
static
|
||||
int rescan_vector_cb(unsigned, unsigned long long, unsigned long long, unsigned,
|
||||
void *ctx) {
|
||||
RescanContext *rctx = (RescanContext *)ctx;
|
||||
RescanContext *rctx = reinterpret_cast<RescanContext *>(ctx);
|
||||
rctx->matches++;
|
||||
|
||||
const string data1 = "___foo_";
|
||||
@@ -221,7 +221,7 @@ TEST(ScratchInUse, Vectored) {
|
||||
static
|
||||
int rescan_realloc_cb(unsigned, unsigned long long, unsigned long long,
|
||||
unsigned, void *ctx) {
|
||||
RescanContext *rctx = (RescanContext *)ctx;
|
||||
RescanContext *rctx = reinterpret_cast<RescanContext *>(ctx);
|
||||
rctx->matches++;
|
||||
|
||||
auto db = makeDatabase("another db", 0, HS_MODE_BLOCK);
|
||||
@@ -251,7 +251,7 @@ TEST(ScratchInUse, ReallocScratchVector) {
|
||||
static
|
||||
int rescan_free_cb(unsigned, unsigned long long, unsigned long long,
|
||||
unsigned, void *ctx) {
|
||||
RescanContext *rctx = (RescanContext *)ctx;
|
||||
RescanContext *rctx = reinterpret_cast<RescanContext *>(ctx);
|
||||
rctx->matches++;
|
||||
|
||||
hs_error_t err = hs_free_scratch(rctx->scratch);
|
||||
|
@@ -41,7 +41,7 @@ using namespace std;
|
||||
|
||||
int record_cb(unsigned id, unsigned long long, unsigned long long to,
|
||||
unsigned, void *ctxt) {
|
||||
CallBackContext *c = (CallBackContext *)ctxt;
|
||||
CallBackContext *c = reinterpret_cast<CallBackContext *>(ctxt);
|
||||
|
||||
c->matches.emplace_back(to, id);
|
||||
|
||||
@@ -189,8 +189,8 @@ void *count_malloc(size_t n) {
|
||||
}
|
||||
|
||||
allocated_count += n;
|
||||
*(size_t *)pp = n;
|
||||
void *p = (char *)pp + 16;
|
||||
*(reinterpret_cast<size_t *>(pp)) = n;
|
||||
void *p = static_cast<char *>(pp) + 16;
|
||||
|
||||
return p;
|
||||
}
|
||||
@@ -200,8 +200,8 @@ void count_free(void *p) {
|
||||
return;
|
||||
}
|
||||
|
||||
void *pp = (char *)p - 16;
|
||||
size_t n = *(size_t *)pp;
|
||||
void *pp = static_cast<char *>(p) - 16;
|
||||
size_t n = *(reinterpret_cast<size_t *>(pp));
|
||||
|
||||
allocated_count -= n;
|
||||
|
||||
@@ -215,8 +215,8 @@ void *count_malloc_b(size_t n) {
|
||||
}
|
||||
|
||||
allocated_count_b += n;
|
||||
*(size_t *)pp = n;
|
||||
void *p = (char *)pp + 32;
|
||||
*(reinterpret_cast<size_t *>(pp)) = n;
|
||||
void *p = static_cast<char *>(pp) + 32;
|
||||
|
||||
return p;
|
||||
}
|
||||
@@ -226,8 +226,8 @@ void count_free_b(void *p) {
|
||||
return;
|
||||
}
|
||||
|
||||
void *pp = (char *)p - 32;
|
||||
size_t n = *(size_t *)pp;
|
||||
void *pp = static_cast<char *>(p) - 32;
|
||||
size_t n = *(reinterpret_cast<size_t *>(pp));
|
||||
|
||||
allocated_count_b -= n;
|
||||
|
||||
|
Reference in New Issue
Block a user