/* * * Copyright 2015 gRPC authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef GRPC_IMPL_SLICE_TYPE_H #define GRPC_IMPL_SLICE_TYPE_H // IWYU pragma: private, include <grpc/slice.h> #include <grpc/support/port_platform.h> #include <stddef.h> grpc_slice; /** Slice API A slice represents a contiguous reference counted array of bytes. It is cheap to take references to a slice, and it is cheap to create a slice pointing to a subset of another slice. The data-structure for slices is exposed here to allow non-gpr code to build slices from whatever data they have available. When defining interfaces that handle slices, care should be taken to define reference ownership semantics (who should call unref?) and mutability constraints (is the callee allowed to modify the slice?) */ /* Inlined half of grpc_slice is allowed to expand the size of the overall type by this many bytes */ #define GRPC_SLICE_INLINE_EXTRA_SIZE … #define GRPC_SLICE_INLINED_SIZE … struct grpc_slice_refcount; /** A grpc_slice s, if initialized, represents the byte range s.bytes[0..s.length-1]. It can have an associated ref count which has a destruction routine to be run when the ref count reaches zero (see grpc_slice_new() and grp_slice_unref()). Multiple grpc_slice values may share a ref count. If the slice does not have a refcount, it represents an inlined small piece of data that is copied by value. As a special case, a slice can be given refcount == uintptr_t(1), meaning that the slice represents external data that is not refcounted. */ struct grpc_slice { … }; #define GRPC_SLICE_BUFFER_INLINE_ELEMENTS … /** Represents an expandable array of slices, to be interpreted as a single item. */ grpc_slice_buffer; #define GRPC_SLICE_START_PTR(slice) … #define GRPC_SLICE_LENGTH(slice) … #define GRPC_SLICE_SET_LENGTH(slice, newlen) … #define GRPC_SLICE_END_PTR(slice) … #define GRPC_SLICE_IS_EMPTY(slice) … #endif /* GRPC_IMPL_SLICE_TYPE_H */