19 #ifndef GRPC_IMPL_CODEGEN_SLICE_H
20 #define GRPC_IMPL_CODEGEN_SLICE_H
66 #define GRPC_SLICE_INLINE_EXTRA_SIZE sizeof(void*)
68 #define GRPC_SLICE_INLINED_SIZE \
69 (sizeof(size_t) + sizeof(uint8_t*) - 1 + GRPC_SLICE_INLINE_EXTRA_SIZE)
94 #define GRPC_SLICE_BUFFER_INLINE_ELEMENTS 8
116 #define GRPC_SLICE_START_PTR(slice) \
117 ((slice).refcount ? (slice).data.refcounted.bytes \
118 : (slice).data.inlined.bytes)
119 #define GRPC_SLICE_LENGTH(slice) \
120 ((slice).refcount ? (slice).data.refcounted.length \
121 : (slice).data.inlined.length)
122 #define GRPC_SLICE_SET_LENGTH(slice, newlen) \
123 ((slice).refcount ? ((slice).data.refcounted.length = (size_t)(newlen)) \
124 : ((slice).data.inlined.length = (uint8_t)(newlen)))
125 #define GRPC_SLICE_END_PTR(slice) \
126 GRPC_SLICE_START_PTR(slice) + GRPC_SLICE_LENGTH(slice)
127 #define GRPC_SLICE_IS_EMPTY(slice) (GRPC_SLICE_LENGTH(slice) == 0)
129 #ifdef GRPC_ALLOW_GPR_SLICE_FUNCTIONS
132 #define GPR_SLICE_START_PTR(slice) \
133 ((slice).refcount ? (slice).data.refcounted.bytes \
134 : (slice).data.inlined.bytes)
135 #define GPR_SLICE_LENGTH(slice) \
136 ((slice).refcount ? (slice).data.refcounted.length \
137 : (slice).data.inlined.length)
138 #define GPR_SLICE_SET_LENGTH(slice, newlen) \
139 ((slice).refcount ? ((slice).data.refcounted.length = (size_t)(newlen)) \
140 : ((slice).data.inlined.length = (uint8_t)(newlen)))
141 #define GPR_SLICE_END_PTR(slice) \
142 GRPC_SLICE_START_PTR(slice) + GRPC_SLICE_LENGTH(slice)
143 #define GPR_SLICE_IS_EMPTY(slice) (GRPC_SLICE_LENGTH(slice) == 0)
struct grpc_slice_refcount_vtable grpc_slice_refcount_vtable
Slice API.
Reference count container for grpc_slice.
Definition: slice.h:55
struct grpc_slice::grpc_slice_data::grpc_slice_inlined inlined
struct grpc_slice_refcount * sub_refcount
If a subset of this slice is taken, use this pointer for the refcount.
Definition: slice.h:61
uint8_t bytes[(sizeof(size_t)+sizeof(uint8_t *)-1+sizeof(void *))]
Definition: slice.h:89
A grpc_slice s, if initialized, represents the byte range s.bytes[0..s.length-1]. ...
Definition: slice.h:80
grpc_slice * slices
slices in the array (Points to the first valid grpc_slice in the array)
Definition: slice.h:104
void(* unref)(void *)
Definition: slice.h:45
Represents an expandable array of slices, to be interpreted as a single item.
Definition: slice.h:98
uint8_t length
Definition: slice.h:88
struct grpc_slice::grpc_slice_data::grpc_slice_refcounted refcounted
void(* ref)(void *)
Definition: slice.h:44
Slice API.
Definition: slice.h:43
size_t length
the combined length of all slices in the array
Definition: slice.h:111
int(* eq)(grpc_slice a, grpc_slice b)
Definition: slice.h:46
struct grpc_slice_refcount * refcount
Definition: slice.h:81
grpc_slice * base_slices
This is for internal use only.
Definition: slice.h:101
size_t length
Definition: slice.h:85
uint32_t(* hash)(grpc_slice slice)
Definition: slice.h:47
size_t capacity
the number of slices allocated in the array.
Definition: slice.h:109
#define GRPC_SLICE_BUFFER_INLINE_ELEMENTS
Definition: slice.h:94
#define GRPC_SLICE_INLINED_SIZE
Definition: slice.h:68
union grpc_slice::grpc_slice_data data
struct grpc_slice_refcount grpc_slice_refcount
Reference count container for grpc_slice.
size_t count
the number of slices in the array
Definition: slice.h:106
const grpc_slice_refcount_vtable * vtable
Definition: slice.h:56
uint8_t * bytes
Definition: slice.h:84