summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Gediminas Jakutis <gediminas@varciai.lt> 2020-02-17 00:10:12 +0200
committerGravatar Gediminas Jakutis <gediminas@varciai.lt> 2020-02-17 00:10:12 +0200
commit790d6dcfc531005a5d7ca2f79460d593d61bb1a0 (patch)
treebf52eaa23dff4e4a9002228dd29d5472352e5bd7
parent3fa68c95644b9a69c0e519987577fb1bb57bf1dc (diff)
downloadalgos-ld1-790d6dcfc531005a5d7ca2f79460d593d61bb1a0.tar.gz
algos-ld1-790d6dcfc531005a5d7ca2f79460d593d61bb1a0.tar.bz2
algos-ld1-790d6dcfc531005a5d7ca2f79460d593d61bb1a0.zip
now sets proper stride.
Signed-off-by: Gediminas Jakutis <gediminas@varciai.lt>
-rw-r--r--src/io.h13
-rw-r--r--src/main.c9
2 files changed, 17 insertions, 5 deletions
diff --git a/src/io.h b/src/io.h
index 79216f2..b7c0ebd 100644
--- a/src/io.h
+++ b/src/io.h
@@ -2,15 +2,28 @@
#define ALGOS_IO_H_INCLUDED
#include <stddef.h>
+#include <stdint.h>
struct stream {
size_t n;
size_t stride;
+ ssize_t last_idx;
int fd;
int out;
char *name;
};
+/* for array implementation */
+struct entry_a {
+ uint64_t val;
+};
+
+/* for linked list implementation */
+struct entry_l {
+ uint32_t i; /* "pointer" to the next element. */
+ uint64_t val;
+};
+
int stream_open(struct stream *in);
int stream_close(struct stream *in);
diff --git a/src/main.c b/src/main.c
index aa3e4b7..29283a6 100644
--- a/src/main.c
+++ b/src/main.c
@@ -17,8 +17,8 @@ static struct settings_s {
unsigned int mode;
} settings = {0};
-static struct stream file_in = {.fd = -1};
-static struct stream file_out = {.fd = -1};
+static struct stream file_in = {.last_idx = -1, .fd = -1};
+static struct stream file_out = {.last_idx = -1, .fd = -1, .out = 1};
static int parseargs(int argc, char **argv, struct settings_s * settings);
void printhelp(const char * const name);
@@ -32,16 +32,15 @@ int main(int argc, char **argv)
}
file_in.name = settings.filein;
- file_in.stride = 0; /* TODO */
+ file_in.stride = settings.mode & DATA_FORMAT ? sizeof(struct entry_l) : sizeof(struct entry_a);
if ((ret = stream_open(&file_in))) {
goto out;
}
file_out.name = settings.fileout ? settings.fileout : settings.filein;
- file_out.out = 1;
file_out.n = file_in.n;
- file_out.stride = 0; /* TODO */
+ file_out.stride = file_in.stride;
if ((ret = stream_open(&file_out))) {
goto out;