Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nanopb
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CodeLinaro
le
nanopb
Commits
5e4356ef
Commit
5e4356ef
authored
9 years ago
by
Petteri Aimonen
Browse files
Options
Downloads
Patches
Plain Diff
Add initialization to examples/simple
parent
6db720aa
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/cmake_simple/simple.c
+6
-3
6 additions, 3 deletions
examples/cmake_simple/simple.c
examples/simple/simple.c
+6
-3
6 additions, 3 deletions
examples/simple/simple.c
with
12 additions
and
6 deletions
examples/cmake_simple/simple.c
+
6
−
3
View file @
5e4356ef
...
...
@@ -15,8 +15,11 @@ int main()
/* Allocate space on the stack to store the message data.
*
* Nanopb generates simple struct definitions for all the messages.
* - check out the contents of simple.pb.h! */
SimpleMessage
message
;
* - check out the contents of simple.pb.h!
* It is a good idea to always initialize your structures
* so that you do not have garbage data from RAM in there.
*/
SimpleMessage
message
=
SimpleMessage_init_zero
;
/* Create a stream that will write to our buffer. */
pb_ostream_t
stream
=
pb_ostream_from_buffer
(
buffer
,
sizeof
(
buffer
));
...
...
@@ -44,7 +47,7 @@ int main()
{
/* Allocate space for the decoded message. */
SimpleMessage
message
;
SimpleMessage
message
=
SimpleMessage_init_zero
;
/* Create a stream that reads from the buffer. */
pb_istream_t
stream
=
pb_istream_from_buffer
(
buffer
,
message_length
);
...
...
This diff is collapsed.
Click to expand it.
examples/simple/simple.c
+
6
−
3
View file @
5e4356ef
...
...
@@ -15,8 +15,11 @@ int main()
/* Allocate space on the stack to store the message data.
*
* Nanopb generates simple struct definitions for all the messages.
* - check out the contents of simple.pb.h! */
SimpleMessage
message
;
* - check out the contents of simple.pb.h!
* It is a good idea to always initialize your structures
* so that you do not have garbage data from RAM in there.
*/
SimpleMessage
message
=
SimpleMessage_init_zero
;
/* Create a stream that will write to our buffer. */
pb_ostream_t
stream
=
pb_ostream_from_buffer
(
buffer
,
sizeof
(
buffer
));
...
...
@@ -44,7 +47,7 @@ int main()
{
/* Allocate space for the decoded message. */
SimpleMessage
message
;
SimpleMessage
message
=
SimpleMessage_init_zero
;
/* Create a stream that reads from the buffer. */
pb_istream_t
stream
=
pb_istream_from_buffer
(
buffer
,
message_length
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment