Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
protobuf-c
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
protobuf-c
Commits
7b4c18a0
Commit
7b4c18a0
authored
Nov 27, 2015
by
Peter Leschev
Committed by
Ilya Lipnitskiy
Dec 12, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #196
parent
7634c0e6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
13 deletions
+27
-13
protobuf-c/protobuf-c.c
protobuf-c/protobuf-c.c
+13
-13
t/generated-code2/test-generated-code2.c
t/generated-code2/test-generated-code2.c
+14
-0
No files found.
protobuf-c/protobuf-c.c
View file @
7b4c18a0
...
...
@@ -258,13 +258,13 @@ get_tag_size(unsigned number)
static
inline
size_t
uint32_size
(
uint32_t
v
)
{
if
(
v
<
(
1
<<
7
))
{
if
(
v
<
(
1
UL
<<
7
))
{
return
1
;
}
else
if
(
v
<
(
1
<<
14
))
{
}
else
if
(
v
<
(
1
UL
<<
14
))
{
return
2
;
}
else
if
(
v
<
(
1
<<
21
))
{
}
else
if
(
v
<
(
1
UL
<<
21
))
{
return
3
;
}
else
if
(
v
<
(
1
<<
28
))
{
}
else
if
(
v
<
(
1
UL
<<
28
))
{
return
4
;
}
else
{
return
5
;
...
...
@@ -285,13 +285,13 @@ int32_size(int32_t v)
{
if
(
v
<
0
)
{
return
10
;
}
else
if
(
v
<
(
1
<<
7
))
{
}
else
if
(
v
<
(
1
UL
<<
7
))
{
return
1
;
}
else
if
(
v
<
(
1
<<
14
))
{
}
else
if
(
v
<
(
1
UL
<<
14
))
{
return
2
;
}
else
if
(
v
<
(
1
<<
21
))
{
}
else
if
(
v
<
(
1
UL
<<
21
))
{
return
3
;
}
else
if
(
v
<
(
1
<<
28
))
{
}
else
if
(
v
<
(
1
UL
<<
28
))
{
return
4
;
}
else
{
return
5
;
...
...
@@ -348,15 +348,15 @@ uint64_size(uint64_t v)
if
(
upper_v
==
0
)
{
return
uint32_size
((
uint32_t
)
v
);
}
else
if
(
upper_v
<
(
1
<<
3
))
{
}
else
if
(
upper_v
<
(
1
UL
<<
3
))
{
return
5
;
}
else
if
(
upper_v
<
(
1
<<
10
))
{
}
else
if
(
upper_v
<
(
1
UL
<<
10
))
{
return
6
;
}
else
if
(
upper_v
<
(
1
<<
17
))
{
}
else
if
(
upper_v
<
(
1
UL
<<
17
))
{
return
7
;
}
else
if
(
upper_v
<
(
1
<<
24
))
{
}
else
if
(
upper_v
<
(
1
UL
<<
24
))
{
return
8
;
}
else
if
(
upper_v
<
(
1U
<<
31
))
{
}
else
if
(
upper_v
<
(
1U
L
<<
31
))
{
return
9
;
}
else
{
return
10
;
...
...
t/generated-code2/test-generated-code2.c
View file @
7b4c18a0
...
...
@@ -2149,6 +2149,18 @@ test_message_check(void)
assert
(
1
==
protobuf_c_message_check
(
&
m
.
base
));
}
static
void
test_large_int_packed_size
(
void
)
{
Foo__TestMessRequiredSInt64
m
=
FOO__TEST_MESS_REQUIRED_SINT64__INIT
;
m
.
test
=
200
;
assert
(
3
==
foo__test_mess_required_sint64__get_packed_size
(
&
m
));
m
.
test
=
32000
;
assert
(
4
==
foo__test_mess_required_sint64__get_packed_size
(
&
m
));
}
/* === simple testing framework === */
typedef
void
(
*
TestFunc
)
(
void
);
...
...
@@ -2284,6 +2296,8 @@ static Test tests[] =
{
"test field flags"
,
test_field_flags
},
{
"test message_check()"
,
test_message_check
},
{
"test large int packed size"
,
test_large_int_packed_size
},
};
#define n_tests (sizeof(tests)/sizeof(Test))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment