byte_buffer.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 
20 
21 #include <stddef.h>
22 
23 #include <grpc/byte_buffer.h>
26 #include <grpc/slice.h>
27 #include <grpc/slice_buffer.h>
28 #include <grpc/support/alloc.h>
29 
33 
35  size_t nslices) {
38 }
39 
41  grpc_slice* slices, size_t nslices,
42  grpc_compression_algorithm compression) {
43  size_t i;
44  grpc_byte_buffer* bb =
45  static_cast<grpc_byte_buffer*>(gpr_malloc(sizeof(grpc_byte_buffer)));
46  bb->type = GRPC_BB_RAW;
47  bb->data.raw.compression = compression;
49  for (i = 0; i < nslices; i++) {
52  }
53  return bb;
54 }
55 
58  grpc_byte_buffer* bb =
59  static_cast<grpc_byte_buffer*>(gpr_malloc(sizeof(grpc_byte_buffer)));
61  bb->type = GRPC_BB_RAW;
64 
67  }
68  return bb;
69 }
70 
72  switch (bb->type) {
73  case GRPC_BB_RAW:
76  bb->data.raw.compression);
77  }
78  GPR_UNREACHABLE_CODE(return nullptr);
79 }
80 
82  if (!bb) return;
84  switch (bb->type) {
85  case GRPC_BB_RAW:
87  break;
88  }
89  gpr_free(bb);
90 }
91 
93  switch (bb->type) {
94  case GRPC_BB_RAW:
95  return bb->data.raw.slice_buffer.length;
96  }
97  GPR_UNREACHABLE_CODE(return 0);
98 }
grpc_slice_ref_internal
const grpc_slice & grpc_slice_ref_internal(const grpc_slice &slice)
Definition: slice_refcount.h:32
grpc_raw_compressed_byte_buffer_create
grpc_byte_buffer * grpc_raw_compressed_byte_buffer_create(grpc_slice *slices, size_t nslices, grpc_compression_algorithm compression)
Definition: byte_buffer.cc:40
slice.h
grpc_byte_buffer::grpc_byte_buffer_data::raw
struct grpc_byte_buffer::grpc_byte_buffer_data::grpc_compressed_buffer raw
grpc_compression_algorithm
grpc_compression_algorithm
Definition: compression_types.h:60
grpc_slice_buffer::slices
grpc_slice * slices
Definition: include/grpc/impl/codegen/slice.h:89
gpr_free
GPRAPI void gpr_free(void *ptr)
Definition: alloc.cc:51
grpc_byte_buffer_reader_next
GRPCAPI int grpc_byte_buffer_reader_next(grpc_byte_buffer_reader *reader, grpc_slice *slice)
Definition: byte_buffer_reader.cc:66
gpr_malloc
GPRAPI void * gpr_malloc(size_t size)
Definition: alloc.cc:29
grpc_raw_byte_buffer_create
grpc_byte_buffer * grpc_raw_byte_buffer_create(grpc_slice *slices, size_t nslices)
Definition: byte_buffer.cc:34
GRPC_COMPRESS_NONE
@ GRPC_COMPRESS_NONE
Definition: compression_types.h:61
grpc_byte_buffer_length
size_t grpc_byte_buffer_length(grpc_byte_buffer *bb)
Definition: byte_buffer.cc:92
GRPC_BB_RAW
@ GRPC_BB_RAW
Definition: grpc_types.h:39
grpc_byte_buffer::type
grpc_byte_buffer_type type
Definition: grpc_types.h:45
grpc_types.h
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_copy
grpc_byte_buffer * grpc_byte_buffer_copy(grpc_byte_buffer *bb)
Definition: byte_buffer.cc:71
grpc_byte_buffer
Definition: grpc_types.h:43
grpc_slice_buffer::length
size_t length
Definition: include/grpc/impl/codegen/slice.h:96
slice_buffer.h
grpc_slice
Definition: include/grpc/impl/codegen/slice.h:65
slice_internal.h
GPR_UNREACHABLE_CODE
#define GPR_UNREACHABLE_CODE(STATEMENT)
Definition: impl/codegen/port_platform.h:652
grpc_core::ExecCtx
Definition: exec_ctx.h:97
grpc_slice_buffer_init
GPRAPI void grpc_slice_buffer_init(grpc_slice_buffer *sb)
Definition: slice/slice_buffer.cc:116
grpc_byte_buffer::data
union grpc_byte_buffer::grpc_byte_buffer_data data
compression_types.h
grpc_slice_buffer_add
GPRAPI void grpc_slice_buffer_add(grpc_slice_buffer *sb, grpc_slice slice)
Definition: slice/slice_buffer.cc:170
exec_ctx
grpc_core::ExecCtx exec_ctx
Definition: end2end_binder_transport_test.cc:75
grpc_raw_byte_buffer_from_reader
grpc_byte_buffer * grpc_raw_byte_buffer_from_reader(grpc_byte_buffer_reader *reader)
Definition: byte_buffer.cc:56
grpc_byte_buffer::grpc_byte_buffer_data::grpc_compressed_buffer::compression
grpc_compression_algorithm compression
Definition: grpc_types.h:51
alloc.h
slices
SliceBuffer * slices
Definition: retry_filter.cc:631
exec_ctx.h
slice_refcount.h
grpc_byte_buffer::grpc_byte_buffer_data::grpc_compressed_buffer::slice_buffer
grpc_slice_buffer slice_buffer
Definition: grpc_types.h:52
grpc_slice_buffer_destroy_internal
void grpc_slice_buffer_destroy_internal(grpc_slice_buffer *sb)
Definition: slice/slice_buffer.cc:123
grpc_byte_buffer_destroy
void grpc_byte_buffer_destroy(grpc_byte_buffer *bb)
Definition: byte_buffer.cc:81
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
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
port_platform.h


grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:58:41