Lines Matching refs:stream

3  * C++ stream style string builder used in KUnit for building messages.
14 #include "string-stream.h"
41 int string_stream_vadd(struct string_stream *stream,
61 if (stream->append_newlines)
67 frag_container = alloc_string_stream_fragment(buf_len, stream->gfp);
71 if (stream->append_newlines) {
82 spin_lock(&stream->lock);
83 stream->length += result_len;
84 list_add_tail(&frag_container->node, &stream->fragments);
85 spin_unlock(&stream->lock);
90 int string_stream_add(struct string_stream *stream, const char *fmt, ...)
96 result = string_stream_vadd(stream, fmt, args);
102 void string_stream_clear(struct string_stream *stream)
106 spin_lock(&stream->lock);
109 &stream->fragments,
113 stream->length = 0;
114 spin_unlock(&stream->lock);
117 char *string_stream_get_string(struct string_stream *stream)
120 size_t buf_len = stream->length + 1; /* +1 for null byte. */
123 buf = kzalloc(buf_len, stream->gfp);
127 spin_lock(&stream->lock);
128 list_for_each_entry(frag_container, &stream->fragments, node)
130 spin_unlock(&stream->lock);
135 int string_stream_append(struct string_stream *stream,
146 ret = string_stream_add(stream, other_content);
152 bool string_stream_is_empty(struct string_stream *stream)
154 return list_empty(&stream->fragments);
159 struct string_stream *stream;
161 stream = kzalloc(sizeof(*stream), gfp);
162 if (!stream)
165 stream->gfp = gfp;
166 INIT_LIST_HEAD(&stream->fragments);
167 spin_lock_init(&stream->lock);
169 return stream;
172 void string_stream_destroy(struct string_stream *stream)
174 KUNIT_STATIC_STUB_REDIRECT(string_stream_destroy, stream);
176 if (IS_ERR_OR_NULL(stream))
179 string_stream_clear(stream);
180 kfree(stream);
185 struct string_stream *stream = p;
187 string_stream_destroy(stream);
192 struct string_stream *stream;
194 stream = alloc_string_stream(gfp);
195 if (IS_ERR(stream))
196 return stream;
198 if (kunit_add_action_or_reset(test, resource_free_string_stream, stream) != 0)
201 return stream;
204 void kunit_free_string_stream(struct kunit *test, struct string_stream *stream)
206 kunit_release_action(test, resource_free_string_stream, (void *)stream);