Lines Matching full:stream
3 * C++ stream style string builder used in KUnit for building messages.
13 #include "string-stream.h"
40 int string_stream_vadd(struct string_stream *stream, in string_stream_vadd() argument
56 frag_container = alloc_string_stream_fragment(stream->test, in string_stream_vadd()
58 stream->gfp); in string_stream_vadd()
63 spin_lock(&stream->lock); in string_stream_vadd()
64 stream->length += len; in string_stream_vadd()
65 list_add_tail(&frag_container->node, &stream->fragments); in string_stream_vadd()
66 spin_unlock(&stream->lock); in string_stream_vadd()
71 int string_stream_add(struct string_stream *stream, const char *fmt, ...) in string_stream_add() argument
77 result = string_stream_vadd(stream, fmt, args); in string_stream_add()
83 static void string_stream_clear(struct string_stream *stream) in string_stream_clear() argument
87 spin_lock(&stream->lock); in string_stream_clear()
90 &stream->fragments, in string_stream_clear()
92 string_stream_fragment_destroy(stream->test, frag_container); in string_stream_clear()
94 stream->length = 0; in string_stream_clear()
95 spin_unlock(&stream->lock); in string_stream_clear()
98 char *string_stream_get_string(struct string_stream *stream) in string_stream_get_string() argument
101 size_t buf_len = stream->length + 1; /* +1 for null byte. */ in string_stream_get_string()
104 buf = kunit_kzalloc(stream->test, buf_len, stream->gfp); in string_stream_get_string()
108 spin_lock(&stream->lock); in string_stream_get_string()
109 list_for_each_entry(frag_container, &stream->fragments, node) in string_stream_get_string()
111 spin_unlock(&stream->lock); in string_stream_get_string()
116 int string_stream_append(struct string_stream *stream, in string_stream_append() argument
126 return string_stream_add(stream, other_content); in string_stream_append()
129 bool string_stream_is_empty(struct string_stream *stream) in string_stream_is_empty() argument
131 return list_empty(&stream->fragments); in string_stream_is_empty()
141 struct string_stream *stream; in alloc_string_stream() local
143 stream = kunit_kzalloc(test, sizeof(*stream), gfp); in alloc_string_stream()
144 if (!stream) in alloc_string_stream()
147 stream->gfp = gfp; in alloc_string_stream()
148 stream->test = test; in alloc_string_stream()
149 INIT_LIST_HEAD(&stream->fragments); in alloc_string_stream()
150 spin_lock_init(&stream->lock); in alloc_string_stream()
152 return stream; in alloc_string_stream()
155 void string_stream_destroy(struct string_stream *stream) in string_stream_destroy() argument
157 string_stream_clear(stream); in string_stream_destroy()