| 155 | } |
| 156 | |
| 157 | struct hc_memory_stream *hc_memory_stream_init(struct hc_memory_stream *s, |
| 158 | struct hc_malloc *malloc) { |
| 159 | s->stream = (struct hc_stream){ |
| 160 | .read = memory_read, |
| 161 | .write = memory_write, |
| 162 | .deinit = memory_deinit, |
| 163 | }; |
| 164 | |
| 165 | hc_vector_init(&s->data, malloc, 1); |
| 166 | s->rpos = 0; |
| 167 | return s; |
| 168 | } |
| 169 | |
| 170 | const char *hc_memory_stream_string(struct hc_memory_stream *s) { |
| 171 | if (!s->data.length || (*(s->data.end-1))) { |