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
a8921fe7
Commit
a8921fe7
authored
Apr 10, 2017
by
Robert Edmonds
Committed by
GitHub
Apr 10, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #267 from pbor/wip/zeroish
Rework is_zeroish one more time
parents
54640671
4ca344ed
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
7 deletions
+37
-7
protobuf-c/protobuf-c.c
protobuf-c/protobuf-c.c
+37
-7
No files found.
protobuf-c/protobuf-c.c
View file @
a8921fe7
...
...
@@ -526,14 +526,44 @@ static protobuf_c_boolean
field_is_zeroish
(
const
ProtobufCFieldDescriptor
*
field
,
const
void
*
member
)
{
if
(
field
->
type
==
PROTOBUF_C_TYPE_MESSAGE
||
field
->
type
==
PROTOBUF_C_TYPE_STRING
)
{
const
void
*
ptr
=
*
(
const
void
*
const
*
)
member
;
if
(
ptr
==
NULL
)
return
TRUE
;
protobuf_c_boolean
ret
=
FALSE
;
switch
(
field
->
type
)
{
case
PROTOBUF_C_TYPE_BOOL
:
ret
=
(
0
==
*
(
const
protobuf_c_boolean
*
)
member
);
break
;
case
PROTOBUF_C_TYPE_ENUM
:
case
PROTOBUF_C_TYPE_SINT32
:
case
PROTOBUF_C_TYPE_INT32
:
case
PROTOBUF_C_TYPE_UINT32
:
case
PROTOBUF_C_TYPE_SFIXED32
:
case
PROTOBUF_C_TYPE_FIXED32
:
ret
=
(
0
==
*
(
const
uint32_t
*
)
member
);
break
;
case
PROTOBUF_C_TYPE_SINT64
:
case
PROTOBUF_C_TYPE_INT64
:
case
PROTOBUF_C_TYPE_UINT64
:
case
PROTOBUF_C_TYPE_SFIXED64
:
case
PROTOBUF_C_TYPE_FIXED64
:
ret
=
(
0
==
*
(
const
uint64_t
*
)
member
);
break
;
case
PROTOBUF_C_TYPE_FLOAT
:
ret
=
(
0
==
*
(
const
float
*
)
member
);
break
;
case
PROTOBUF_C_TYPE_DOUBLE
:
ret
=
(
0
==
*
(
const
double
*
)
member
);
break
;
case
PROTOBUF_C_TYPE_STRING
:
case
PROTOBUF_C_TYPE_BYTES
:
case
PROTOBUF_C_TYPE_MESSAGE
:
ret
=
(
NULL
==
*
(
const
void
*
const
*
)
member
);
break
;
default:
ret
=
TRUE
;
break
;
}
return
member
==
NULL
;
return
ret
;
}
/**
...
...
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