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