Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
y
z
Enumerations
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
Enumerator
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
z
Classes
Class List
Class Hierarchy
Class Members
All
:
[
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
[
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
y
Enumerations
a
b
c
d
e
f
h
i
k
l
m
n
o
p
r
s
t
u
v
w
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
z
Properties
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
Related Functions
:
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
z
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Enumerations
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
grpc
src
core
lib
surface
byte_buffer_reader.cc
Go to the documentation of this file.
1
/*
2
*
3
* Copyright 2015 gRPC authors.
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
16
*
17
*/
18
19
#include <
grpc/support/port_platform.h
>
20
21
#include <
stdint.h
>
22
#include <
string.h
>
23
24
#include <grpc/byte_buffer.h>
25
#include <
grpc/byte_buffer_reader.h
>
26
#include <
grpc/impl/codegen/grpc_types.h
>
27
#include <
grpc/slice.h
>
28
#include <
grpc/support/log.h
>
29
30
#include "
src/core/lib/iomgr/exec_ctx.h
"
31
#include "
src/core/lib/slice/slice_refcount.h
"
32
33
int
grpc_byte_buffer_reader_init
(
grpc_byte_buffer_reader
*
reader
,
34
grpc_byte_buffer
*
buffer
) {
35
reader
->buffer_in =
buffer
;
36
switch
(
reader
->buffer_in->type) {
37
case
GRPC_BB_RAW
:
38
reader
->buffer_out =
reader
->buffer_in;
39
reader
->current.index = 0;
40
break
;
41
}
42
return
1;
43
}
44
45
void
grpc_byte_buffer_reader_destroy
(
grpc_byte_buffer_reader
*
reader
) {
46
reader
->buffer_out =
nullptr
;
47
}
48
49
int
grpc_byte_buffer_reader_peek
(
grpc_byte_buffer_reader
*
reader
,
50
grpc_slice
**
slice
) {
51
switch
(
reader
->buffer_in->type) {
52
case
GRPC_BB_RAW
: {
53
grpc_slice_buffer
* slice_buffer;
54
slice_buffer = &
reader
->buffer_out->data.raw.slice_buffer;
55
if
(
reader
->current.index < slice_buffer->
count
) {
56
*
slice
= &slice_buffer->
slices
[
reader
->current.index];
57
reader
->current.index += 1;
58
return
1;
59
}
60
break
;
61
}
62
}
63
return
0;
64
}
65
66
int
grpc_byte_buffer_reader_next
(
grpc_byte_buffer_reader
*
reader
,
67
grpc_slice
*
slice
) {
68
switch
(
reader
->buffer_in->type) {
69
case
GRPC_BB_RAW
: {
70
grpc_slice_buffer
* slice_buffer;
71
slice_buffer = &
reader
->buffer_out->data.raw.slice_buffer;
72
if
(
reader
->current.index < slice_buffer->
count
) {
73
*
slice
=
grpc_slice_ref_internal
(
74
slice_buffer->
slices
[
reader
->current.index]);
75
reader
->current.index += 1;
76
return
1;
77
}
78
break
;
79
}
80
}
81
return
0;
82
}
83
84
grpc_slice
grpc_byte_buffer_reader_readall
(
grpc_byte_buffer_reader
*
reader
) {
85
grpc_slice
in_slice;
86
size_t
bytes_read
= 0;
87
const
size_t
input_size =
grpc_byte_buffer_length
(
reader
->buffer_out);
88
grpc_slice
out_slice =
GRPC_SLICE_MALLOC
(input_size);
89
uint8_t
*
const
outbuf
=
GRPC_SLICE_START_PTR
(out_slice);
/* just an alias */
90
91
grpc_core::ExecCtx
exec_ctx
;
92
while
(
grpc_byte_buffer_reader_next
(
reader
, &in_slice) != 0) {
93
const
size_t
slice_length =
GRPC_SLICE_LENGTH
(in_slice);
94
memcpy
(&(
outbuf
[
bytes_read
]),
GRPC_SLICE_START_PTR
(in_slice), slice_length);
95
bytes_read
+= slice_length;
96
grpc_slice_unref_internal
(in_slice);
97
GPR_ASSERT
(
bytes_read
<= input_size);
98
}
99
100
return
out_slice;
101
}
log.h
grpc_slice_ref_internal
const grpc_slice & grpc_slice_ref_internal(const grpc_slice &slice)
Definition:
slice_refcount.h:32
slice.h
string.h
grpc_byte_buffer_reader_next
int grpc_byte_buffer_reader_next(grpc_byte_buffer_reader *reader, grpc_slice *slice)
Definition:
byte_buffer_reader.cc:66
outbuf
unsigned char outbuf[SIZE]
Definition:
bloaty/third_party/zlib/examples/gun.c:162
grpc_byte_buffer_length
GRPCAPI size_t grpc_byte_buffer_length(grpc_byte_buffer *bb)
Definition:
byte_buffer.cc:92
grpc_slice_buffer::slices
grpc_slice * slices
Definition:
include/grpc/impl/codegen/slice.h:89
GRPC_SLICE_MALLOC
#define GRPC_SLICE_MALLOC(len)
Definition:
include/grpc/slice.h:70
uint8_t
unsigned char uint8_t
Definition:
stdint-msvc2008.h:78
grpc_byte_buffer_reader_init
int grpc_byte_buffer_reader_init(grpc_byte_buffer_reader *reader, grpc_byte_buffer *buffer)
Definition:
byte_buffer_reader.cc:33
GRPC_BB_RAW
@ GRPC_BB_RAW
Definition:
grpc_types.h:39
byte_buffer_reader.h
grpc_types.h
memcpy
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
GPR_ASSERT
#define GPR_ASSERT(x)
Definition:
include/grpc/impl/codegen/log.h:94
grpc_byte_buffer_reader_readall
grpc_slice grpc_byte_buffer_reader_readall(grpc_byte_buffer_reader *reader)
Definition:
byte_buffer_reader.cc:84
grpc_slice_buffer::count
size_t count
Definition:
include/grpc/impl/codegen/slice.h:91
slice
grpc_slice slice
Definition:
src/core/lib/surface/server.cc:467
grpc_byte_buffer_reader_peek
int grpc_byte_buffer_reader_peek(grpc_byte_buffer_reader *reader, grpc_slice **slice)
Definition:
byte_buffer_reader.cc:49
grpc_byte_buffer
Definition:
grpc_types.h:43
bytes_read
static size_t bytes_read
Definition:
test-ipc-heavy-traffic-deadlock-bug.c:47
grpc_byte_buffer_reader_destroy
void grpc_byte_buffer_reader_destroy(grpc_byte_buffer_reader *reader)
Definition:
byte_buffer_reader.cc:45
GRPC_SLICE_START_PTR
#define GRPC_SLICE_START_PTR(slice)
Definition:
include/grpc/impl/codegen/slice.h:101
grpc_slice
Definition:
include/grpc/impl/codegen/slice.h:65
buffer
char buffer[1024]
Definition:
libuv/docs/code/idle-compute/main.c:8
grpc_core::ExecCtx
Definition:
exec_ctx.h:97
stdint.h
GRPC_SLICE_LENGTH
#define GRPC_SLICE_LENGTH(slice)
Definition:
include/grpc/impl/codegen/slice.h:104
exec_ctx
grpc_core::ExecCtx exec_ctx
Definition:
end2end_binder_transport_test.cc:75
exec_ctx.h
slice_refcount.h
grpc_slice_buffer
Definition:
include/grpc/impl/codegen/slice.h:83
grpc_byte_buffer_reader
Definition:
impl/codegen/byte_buffer_reader.h:30
reader
void reader(void *n)
Definition:
libuv/docs/code/locks/main.c:8
grpc_slice_unref_internal
void grpc_slice_unref_internal(const grpc_slice &slice)
Definition:
slice_refcount.h:39
port_platform.h
grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:58:41