forked from Kreijstal/fmem
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfmem.h.in
More file actions
69 lines (57 loc) · 1.88 KB
/
fmem.h.in
File metadata and controls
69 lines (57 loc) · 1.88 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef FMEM_H_
#define FMEM_H_
#include <stdio.h>
@EXPORT_MACROS@
struct fmem_reserved {
char reserved[32];
};
typedef struct fmem_reserved fmem;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Initializes an fmem structure.
*
* This function prepares the fmem structure for use. It must be called
* before any other fmem functions are used with this structure.
*
* @param file A pointer to an fmem structure.
*/
FMEM_API void fmem_init(fmem *file);
/**
* Cleans up an fmem structure.
*
* This function releases any resources held by the fmem structure.
* It should be called when you are finished with the structure to prevent memory leaks.
*
* @param file A pointer to an fmem structure.
*/
FMEM_API void fmem_term(fmem *file);
/**
* Opens a memory-backed file stream.
*
* This function attempts to open a memory-backed file stream, trying various
* methods depending on platform support (e.g., open_memstream, fopencookie).
* The 'mode' parameter is currently ignored, and streams are always opened
* in write-only mode.
*
* @param file A pointer to an fmem structure.
* @param mode A string representing the file mode (ignored in current implementation).
* @return A FILE pointer to the memory-backed file stream, or NULL if the operation fails.
*/
FMEM_API FILE *fmem_open(fmem *file, const char *mode);
/**
* Retrieves the memory buffer and size from an fmem structure.
*
* This function allows access to the underlying memory buffer used by the fmem structure.
* It is useful for reading data written to the memory-backed file stream.
*
* @param file A pointer to an fmem structure.
* @param mem A pointer to a pointer where the address of the memory buffer will be stored.
* @param size A pointer to a size_t where the size of the buffer will be stored.
*/
FMEM_API void fmem_mem(fmem *file, void **mem, size_t *size);
#ifdef __cplusplus
}
#endif
#endif /* !FMEM_H_ */