Lines Matching refs:stream
3 * C++ stream style string builder used in KUnit for building messages.
13 #include "string-stream.h"
42 int string_stream_vadd(struct string_stream *stream,
58 frag_container = alloc_string_stream_fragment(stream->test,
60 stream->gfp);
65 spin_lock(&stream->lock);
66 stream->length += len;
67 list_add_tail(&frag_container->node, &stream->fragments);
68 spin_unlock(&stream->lock);
73 int string_stream_add(struct string_stream *stream, const char *fmt, ...)
79 result = string_stream_vadd(stream, fmt, args);
85 static void string_stream_clear(struct string_stream *stream)
89 spin_lock(&stream->lock);
92 &stream->fragments,
94 string_stream_fragment_destroy(stream->test, frag_container);
96 stream->length = 0;
97 spin_unlock(&stream->lock);
100 char *string_stream_get_string(struct string_stream *stream)
103 size_t buf_len = stream->length + 1; /* +1 for null byte. */
106 buf = kunit_kzalloc(stream->test, buf_len, stream->gfp);
110 spin_lock(&stream->lock);
111 list_for_each_entry(frag_container, &stream->fragments, node)
113 spin_unlock(&stream->lock);
118 int string_stream_append(struct string_stream *stream,
128 return string_stream_add(stream, other_content);
131 bool string_stream_is_empty(struct string_stream *stream)
133 return list_empty(&stream->fragments);
138 struct string_stream *stream;
140 stream = kunit_kzalloc(test, sizeof(*stream), gfp);
141 if (!stream)
144 stream->gfp = gfp;
145 stream->test = test;
146 INIT_LIST_HEAD(&stream->fragments);
147 spin_lock_init(&stream->lock);
149 return stream;
152 void string_stream_destroy(struct string_stream *stream)
154 string_stream_clear(stream);