Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit53cc471

Browse files
kostyafipГригорьев Костяnataraj-hates-MS-for-stealing-github
committed
changed dict in stamp constructor from reference to shared ptr (#1)
* changed dict in stamp constructor from reference to shared ptr---------Co-authored-by: Григорьев Костя <kostyafip@mail.ru>Co-authored-by: nataraj-hates-MS-for-stealing-github <48326335+nataraj-hates-MS-for-stealing-github@users.noreply.github.com>
1 parentd8f0863 commit53cc471

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

‎blobstamper/stamp_dict.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@
2222
#include"stamp_dict.h"
2323

2424
int
25-
StampDict::ChooseStampSize(DictBase & dict)
25+
StampDict::ChooseStampSize(std::shared_ptr<DictBase> dict)
2626
{
27-
if (dict.size()<= UCHAR_MAX+1)
27+
if (dict->size()<= UCHAR_MAX+1)
2828
{
2929
stamp_max_value = UCHAR_MAX;
3030
return1;
3131
}
32-
if (dict.size()<= USHRT_MAX+1)
32+
if (dict->size()<= USHRT_MAX+1)
3333
{
3434
stamp_max_value = USHRT_MAX;
3535
return2;
3636
}
37-
if (dict.size()<= UINT_MAX+1)
37+
if (dict->size()<= UINT_MAX+1)
3838
{
3939
stamp_max_value = UINT_MAX;
4040
return4;
@@ -75,7 +75,7 @@ StampDict::ExtractStr(Blob &blob)
7575
printf("StampDict::ExtractStr: Something is really wrong\n");// FIXME better to throw something here :-)
7676
exit(1);
7777
}
78-
longlong actual_index = ((double) index_oracle) / stamp_max_value * dict.size();
79-
if ( actual_index == dict.size()) actual_index--;/* If we hit the boundary step inside a bit*/
80-
return dict.get(actual_index);
78+
longlong actual_index = ((double) index_oracle) / stamp_max_value * dict->size();
79+
if ( actual_index == dict->size()) actual_index--;/* If we hit the boundary step inside a bit*/
80+
return dict->get(actual_index);
8181
}

‎blobstamper/stamp_dict.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include"stamp.h"
2626
#include"stamp_arithm.h"
2727
#include"dict.h"
28+
#include<memory>
2829

2930
classStampDict:publicStampBaseStr
3031
{
@@ -34,13 +35,13 @@ class StampDict: public StampBaseStr
3435
StampArithm<unsignedint> stamp32;
3536
StampArithm<unsignedlonglong> stamp64;
3637
int stamp_size;
37-
DictBase& dict;
38+
std::shared_ptr<DictBase> dict;
3839
unsignedlonglong stamp_max_value;
3940

40-
intChooseStampSize(DictBase & dict);
41+
intChooseStampSize(std::shared_ptr<DictBase> dict);
4142

4243
public:
43-
StampDict(DictBase &dict_arg) : dict{dict_arg}, stamp_size{ChooseStampSize(dict_arg)} {};
44+
StampDict(std::shared_ptr<DictBase>dict_arg) : dict(dict_arg), stamp_size(ChooseStampSize(dict_arg)) {};
4445
std::stringExtractStr(Blob &blob)override;
4546
intminSize()override {return stamp_size;}
4647
intmaxSize()override {return stamp_size;}

‎examples/exampleZZ.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ char data[] =
5454

5555
StampArithm<unsignedchar> stampс;
5656

57-
DictLCAlphaSmall dict;
57+
auto dict = std::make_shared<DictLCAlphaSmall>();
5858
StampDictstamp_dict(dict);
5959

6060
StampLottery4Recursion<StampBaseStr>stamp_lot({stampс, stamp_dict});

‎t/120-stamp_dict.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ main()
4848
{
4949
TEST_START(4);
5050
{/* 1..4*/
51-
DictTest dict;
51+
auto dict = std::make_shared<DictTest>();
5252
StampDictstamp(dict);
5353
Blobblob((char *) sample,4);
5454
std::string s;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp