GRPC Core  4.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
slice_buffer.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015, Google Inc.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above
13  * copyright notice, this list of conditions and the following disclaimer
14  * in the documentation and/or other materials provided with the
15  * distribution.
16  * * Neither the name of Google Inc. nor the names of its
17  * contributors may be used to endorse or promote products derived from
18  * this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
33 
34 #ifndef GRPC_SLICE_BUFFER_H
35 #define GRPC_SLICE_BUFFER_H
36 
37 #include <grpc/slice.h>
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
59  grpc_slice slice);
61  size_t n);
64 GPRAPI uint8_t *grpc_slice_buffer_tiny_add(grpc_slice_buffer *sb, size_t len);
73  grpc_slice_buffer *dst);
76  grpc_slice_buffer *garbage);
79  grpc_slice_buffer *dst);
82  size_t n,
83  grpc_slice_buffer *dst);
86  grpc_slice_buffer *src,
87  size_t n, void *dst);
92  grpc_slice slice);
93 
94 #ifdef __cplusplus
95 }
96 #endif
97 
98 #endif /* GRPC_SLICE_BUFFER_H */
GPRAPI void grpc_slice_buffer_destroy(grpc_slice_buffer *sb)
destroy a slice buffer - unrefs any held elements
GPRAPI void grpc_slice_buffer_undo_take_first(grpc_slice_buffer *src, grpc_slice slice)
undo the above with (a possibly different) slice
GPRAPI void grpc_slice_buffer_move_first_no_ref(grpc_slice_buffer *src, size_t n, grpc_slice_buffer *dst)
move the first n bytes of src into dst without adding references
GPRAPI uint8_t * grpc_slice_buffer_tiny_add(grpc_slice_buffer *sb, size_t len)
add a very small (less than 8 bytes) amount of data to the end of a slice buffer: returns a pointer i...
GPRAPI grpc_slice grpc_slice_buffer_take_first(grpc_slice_buffer *src)
take the first slice in the slice buffer
GPRAPI size_t grpc_slice_buffer_add_indexed(grpc_slice_buffer *sb, grpc_slice slice)
add an element to a slice buffer - takes ownership of the slice and returns the index of the slice...
A grpc_slice s, if initialized, represents the byte range s.bytes[0..s.length-1]. ...
Definition: slice.h:91
#define GPRAPI
Definition: port_platform.h:416
Represents an expandable array of slices, to be interpreted as a single item.
Definition: slice.h:109
GPRAPI void grpc_slice_buffer_addn(grpc_slice_buffer *sb, grpc_slice *slices, size_t n)
GPRAPI void grpc_slice_buffer_reset_and_unref(grpc_slice_buffer *sb)
clear a slice buffer, unref all elements
GPRAPI void grpc_slice_buffer_init(grpc_slice_buffer *sb)
initialize a slice buffer
GPRAPI void grpc_slice_buffer_move_first(grpc_slice_buffer *src, size_t n, grpc_slice_buffer *dst)
move the first n bytes of src into dst
struct grpc_exec_ctx grpc_exec_ctx
Definition: exec_ctx_fwd.h:39
GPRAPI void grpc_slice_buffer_pop(grpc_slice_buffer *sb)
pop the last buffer, but don't unref it
GPRAPI void grpc_slice_buffer_add(grpc_slice_buffer *sb, grpc_slice slice)
Add an element to a slice buffer - takes ownership of the slice.
GPRAPI void grpc_slice_buffer_trim_end(grpc_slice_buffer *src, size_t n, grpc_slice_buffer *garbage)
remove n bytes from the end of a slice buffer
GPRAPI void grpc_slice_buffer_swap(grpc_slice_buffer *a, grpc_slice_buffer *b)
swap the contents of two slice buffers
GPRAPI void grpc_slice_buffer_move_first_into_buffer(grpc_exec_ctx *exec_ctx, grpc_slice_buffer *src, size_t n, void *dst)
move the first n bytes of src into dst (copying them)
GPRAPI void grpc_slice_buffer_move_into(grpc_slice_buffer *src, grpc_slice_buffer *dst)
move all of the elements of src into dst