Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
tci-gateway-module
Grpc
Commits
a324c4fe
Commit
a324c4fe
authored
8 years ago
by
yang-g
Browse files
Options
Downloads
Patches
Plain Diff
Add API to get c slice from c++ Slice.
parent
d605b633
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/grpc++/support/slice.h
+3
-0
3 additions, 0 deletions
include/grpc++/support/slice.h
test/cpp/util/slice_test.cc
+10
-0
10 additions, 0 deletions
test/cpp/util/slice_test.cc
with
13 additions
and
0 deletions
include/grpc++/support/slice.h
+
3
−
0
View file @
a324c4fe
...
...
@@ -77,6 +77,9 @@ class Slice GRPC_FINAL {
/// Raw pointer to the end (one byte \em past the last element) of the slice.
const
uint8_t
*
end
()
const
{
return
GPR_SLICE_END_PTR
(
slice_
);
}
/// Raw C slice. Caller needs to call gpr_slice_unref when done.
gpr_slice
c_slice
()
const
{
return
gpr_slice_ref
(
slice_
);
}
private
:
friend
class
ByteBuffer
;
...
...
This diff is collapsed.
Click to expand it.
test/cpp/util/slice_test.cc
+
10
−
0
View file @
a324c4fe
...
...
@@ -68,6 +68,16 @@ TEST_F(SliceTest, Empty) {
CheckSlice
(
empty_slice
,
""
);
}
TEST_F
(
SliceTest
,
Cslice
)
{
gpr_slice
s
=
gpr_slice_from_copied_string
(
kContent
);
Slice
spp
(
s
,
Slice
::
STEAL_REF
);
CheckSlice
(
spp
,
kContent
);
gpr_slice
c_slice
=
spp
.
c_slice
();
EXPECT_EQ
(
GPR_SLICE_START_PTR
(
s
),
GPR_SLICE_START_PTR
(
c_slice
));
EXPECT_EQ
(
GPR_SLICE_END_PTR
(
s
),
GPR_SLICE_END_PTR
(
c_slice
));
gpr_slice_unref
(
c_slice
);
}
}
// namespace
}
// namespace grpc
...
...
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