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

Commitbf3f011

Browse files
Move shifting N bytes from blob to Blob method
1 parente6668a6 commitbf3f011

File tree

3 files changed

+30
-9
lines changed

3 files changed

+30
-9
lines changed

‎libblobstamper.cpp‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,20 +87,20 @@ Blob::Dump()
8787
}
8888

8989
Blob
90-
wflShiftN(Blob &blob,size_t n)
90+
Blob::ShiftBytes(size_t n)
9191
{
92-
if (blob.begin + n >blob.end)
92+
if (begin + n > end)
9393
{
9494
Blobempty(NULL, -1);
95-
return empty;/*not enough data*/
95+
return empty;/*not enough data*/
9696
}
9797

98-
Blobnew_blob(blob.data,blob.size);
98+
Blobnew_blob(data, size);
9999

100-
new_blob.begin =blob.begin;
101-
new_blob.end =blob.begin + n -1;
100+
new_blob.begin = begin;/* FIXME this should go private once*/
101+
new_blob.end = begin + n -1;
102102

103-
blob.begin += n;
103+
begin += n;
104104

105105
return new_blob;
106106
}
@@ -114,7 +114,7 @@ wflShiftDouble(Blob &blob)
114114
std::string res;
115115

116116

117-
Blob b2 =wflShiftN(blob,sizeof(double));
117+
Blob b2 = blob.ShiftBytes(sizeof(double));
118118
if (b2.isEmpty())return"";
119119

120120
d = (double *)( (char*)b2.data + b2.begin);

‎libblobstamper.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ class Blob
77
Blob(char * data,int size);
88
boolisEmpty ();
99
voidDump();
10+
BlobShiftBytes(size_t n);
1011

1112
char * data;/*FIXME потом сделать private*/
1213
int size;
1314
int begin;
1415
int end;
15-
1616
};
1717

1818
BlobwflShiftN(Blob &blob,size_t n);

‎test_libblobstamper.cpp‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,29 @@ int
88
main(void)
99
{
1010
Blobbl(my_data,strlen(my_data));
11+
12+
printf("Original blob:\n");
13+
1114
bl.Dump();
1215

16+
printf("\n Now shifting 3 bytes.\n");
17+
Blob bl2 = bl.ShiftBytes(3);
18+
19+
printf("Bytes shifted:\n");
20+
bl2.Dump();
21+
22+
printf("\n Remaining blob:\n");
23+
bl.Dump();
24+
25+
printf("\n Now shifting too many bytes.\n");
26+
27+
Blob bl3 = bl.ShiftBytes(99999);
28+
29+
if (bl3.isEmpty())
30+
printf("Got empty result. All is right\n");
31+
else
32+
printf("got non-empty result. SOMETHING IS REALLY WRONG!!!!\n");
33+
1334

1435
return0;
1536
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp