diff options
| author | jakob <jakob@memeware.net> | 2017-02-14 18:47:57 -0500 |
|---|---|---|
| committer | jakob <jakob@memeware.net> | 2017-02-14 18:47:57 -0500 |
| commit | 1fc6cc323dbaa5387d84630615c0d4cab0c1c5ba (patch) | |
| tree | c94a738cb6d7f06fde68fc0765ccfd6a6dd19f4b /src/io.h | |
| parent | 01d185f31ff7194773342881fa0e0a550b5d5c5a (diff) | |
Implemented a basic parser for the XP3 header.
Diffstat (limited to 'src/io.h')
| -rw-r--r-- | src/io.h | 18 |
1 files changed, 8 insertions, 10 deletions
@@ -26,32 +26,30 @@ segment. Used for freeing and unmapping purposes, if necessary. */ enum _location { HEAP, -} +}; /* Structure to emulate a stream of data that maintains a current position. The structure additionally maintains a `length` variable containing the stream's length. */ struct stream { size_t len; /* Length of the stream. */ - void *_start; /* Pointer to the stream's start. */ - void *_cur; /* Pointer to the current position. */ + char *_start; /* Pointer to the stream's start. */ + char *_cur; /* Pointer to the current position. */ enum _location _loc; /* Location of the stream in memory. */ -} +}; -/* Allocates `len` bytes of memory and returns a new stream pointing to - it. The memory provided has not zeroed. */ +/* Allocates `len` bytes of non-zeroed memory and returns a new stream + structure pointing to it. */ struct stream *stream_new(size_t len); /* Called to free or unmap the memory chunk associated with the given stream, as well as the stream structure itself. */ void stream_free(struct stream *s); - /* Copies `n` bytes from the given stream into the memory area specified - by `dest`. The stream is advanced appropriately. */ + by `dest`. The stream's cursor is advanced appropriately. */ void stream_read(void *dest, struct stream *s, size_t n); - /* Copies `n` bytes into the given stream from the memory area specified - by `src`. The stream is advanced appropriately. */ + by `src`. The stream's cursor is advanced appropriately. */ void stream_write(struct stream *s, void *src, size_t n); |