Lines Matching refs:stream
73 int string_stream_vadd(struct string_stream *stream, in string_stream_vadd() argument
89 frag_container = alloc_string_stream_fragment(stream->test, in string_stream_vadd()
91 stream->gfp); in string_stream_vadd()
96 spin_lock(&stream->lock); in string_stream_vadd()
97 stream->length += len; in string_stream_vadd()
98 list_add_tail(&frag_container->node, &stream->fragments); in string_stream_vadd()
99 spin_unlock(&stream->lock); in string_stream_vadd()
104 int string_stream_add(struct string_stream *stream, const char *fmt, ...) in string_stream_add() argument
110 result = string_stream_vadd(stream, fmt, args); in string_stream_add()
116 static void string_stream_clear(struct string_stream *stream) in string_stream_clear() argument
120 spin_lock(&stream->lock); in string_stream_clear()
123 &stream->fragments, in string_stream_clear()
127 stream->length = 0; in string_stream_clear()
128 spin_unlock(&stream->lock); in string_stream_clear()
131 char *string_stream_get_string(struct string_stream *stream) in string_stream_get_string() argument
134 size_t buf_len = stream->length + 1; /* +1 for null byte. */ in string_stream_get_string()
137 buf = kunit_kzalloc(stream->test, buf_len, stream->gfp); in string_stream_get_string()
141 spin_lock(&stream->lock); in string_stream_get_string()
142 list_for_each_entry(frag_container, &stream->fragments, node) in string_stream_get_string()
144 spin_unlock(&stream->lock); in string_stream_get_string()
149 int string_stream_append(struct string_stream *stream, in string_stream_append() argument
159 return string_stream_add(stream, other_content); in string_stream_append()
162 bool string_stream_is_empty(struct string_stream *stream) in string_stream_is_empty() argument
164 return list_empty(&stream->fragments); in string_stream_is_empty()
174 struct string_stream *stream; in string_stream_init() local
177 stream = kunit_kzalloc(ctx->test, sizeof(*stream), ctx->gfp); in string_stream_init()
178 if (!stream) in string_stream_init()
181 res->data = stream; in string_stream_init()
182 stream->gfp = ctx->gfp; in string_stream_init()
183 stream->test = ctx->test; in string_stream_init()
184 INIT_LIST_HEAD(&stream->fragments); in string_stream_init()
185 spin_lock_init(&stream->lock); in string_stream_init()
192 struct string_stream *stream = res->data; in string_stream_free() local
194 string_stream_clear(stream); in string_stream_free()
211 int string_stream_destroy(struct string_stream *stream) in string_stream_destroy() argument
213 return kunit_destroy_resource(stream->test, in string_stream_destroy()
215 stream); in string_stream_destroy()