File: memory-stream.h

package info (click to toggle)
libdisplay-info 0.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,460 kB
  • sloc: ansic: 10,055; python: 294; sh: 131; makefile: 3
file content (32 lines) | stat: -rw-r--r-- 542 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#ifndef MEMORY_STREAM_H
#define MEMORY_STREAM_H

/**
 * Utility functions for memory streams.
 */

#include <stdio.h>
#include <stddef.h>
#include <stdbool.h>

struct memory_stream {
	FILE *fp;
	char *str;
	size_t str_len;
};

bool
memory_stream_open(struct memory_stream *m);

char *
memory_stream_close(struct memory_stream *m);

/**
 * A small cleanup helper that simply
 * calls free(memory_stream_close(m)) to avoid
 * any dangling string pointers in cleanup/error paths.
 */
void
memory_stream_cleanup(struct memory_stream *m);

#endif