Go to the documentation of this file.
19 #ifndef GRPC_IMPL_CODEGEN_SLICE_H
20 #define GRPC_IMPL_CODEGEN_SLICE_H
45 #define GRPC_SLICE_INLINE_EXTRA_SIZE sizeof(void*)
47 #define GRPC_SLICE_INLINED_SIZE \
48 (sizeof(size_t) + sizeof(uint8_t*) - 1 + GRPC_SLICE_INLINE_EXTRA_SIZE)
50 struct grpc_slice_refcount;
74 #define GRPC_SLICE_BUFFER_INLINE_ELEMENTS 8
96 #define GRPC_SLICE_START_PTR(slice) \
97 ((slice).refcount ? (slice).data.refcounted.bytes \
98 : (slice).data.inlined.bytes)
99 #define GRPC_SLICE_LENGTH(slice) \
100 ((slice).refcount ? (slice).data.refcounted.length \
101 : (slice).data.inlined.length)
102 #define GRPC_SLICE_SET_LENGTH(slice, newlen) \
103 ((slice).refcount ? ((slice).data.refcounted.length = (size_t)(newlen)) \
104 : ((slice).data.inlined.length = (uint8_t)(newlen)))
105 #define GRPC_SLICE_END_PTR(slice) \
106 GRPC_SLICE_START_PTR(slice) + GRPC_SLICE_LENGTH(slice)
107 #define GRPC_SLICE_IS_EMPTY(slice) (GRPC_SLICE_LENGTH(slice) == 0)
109 #ifdef GRPC_ALLOW_GPR_SLICE_FUNCTIONS
112 #define GPR_SLICE_START_PTR(slice) \
113 ((slice).refcount ? (slice).data.refcounted.bytes \
114 : (slice).data.inlined.bytes)
115 #define GPR_SLICE_LENGTH(slice) \
116 ((slice).refcount ? (slice).data.refcounted.length \
117 : (slice).data.inlined.length)
118 #define GPR_SLICE_SET_LENGTH(slice, newlen) \
119 ((slice).refcount ? ((slice).data.refcounted.length = (size_t)(newlen)) \
120 : ((slice).data.inlined.length = (uint8_t)(newlen)))
121 #define GPR_SLICE_END_PTR(slice) \
122 GRPC_SLICE_START_PTR(slice) + GRPC_SLICE_LENGTH(slice)
123 #define GPR_SLICE_IS_EMPTY(slice) (GRPC_SLICE_LENGTH(slice) == 0)
uint8_t bytes[(sizeof(size_t)+sizeof(uint8_t *) - 1+sizeof(void *))]
Definition: slice.h:69
grpc_slice inlined[8]
inlined elements to avoid allocations
Definition: slice.h:93
struct grpc_slice_refcount * refcount
Definition: slice.h:61
size_t length
Definition: slice.h:64
#define GRPC_SLICE_BUFFER_INLINE_ELEMENTS
Definition: slice.h:74
grpc_slice * slices
slices in the array (Points to the first valid grpc_slice in the array)
Definition: slice.h:84
struct grpc_slice_buffer grpc_slice_buffer
Represents an expandable array of slices, to be interpreted as a single item.
uint8_t length
Definition: slice.h:68
size_t count
the number of slices in the array
Definition: slice.h:86
size_t length
the combined length of all slices in the array
Definition: slice.h:91
A grpc_slice s, if initialized, represents the byte range s.bytes[0..s.length-1].
Definition: slice.h:60
union grpc_slice::grpc_slice_data data
struct grpc_slice::grpc_slice_data::grpc_slice_inlined inlined
grpc_slice * base_slices
This is for internal use only.
Definition: slice.h:81
uint8_t * bytes
Definition: slice.h:65
struct grpc_slice::grpc_slice_data::grpc_slice_refcounted refcounted
#define GRPC_SLICE_INLINED_SIZE
Definition: slice.h:47
size_t capacity
the number of slices allocated in the array.
Definition: slice.h:89
Represents an expandable array of slices, to be interpreted as a single item.
Definition: slice.h:78