diff --git a/Implementierung/Makefile b/Implementierung/Makefile index 1e99976..205f196 100644 --- a/Implementierung/Makefile +++ b/Implementierung/Makefile @@ -36,9 +36,9 @@ md2: ${OBJ} t/%: @mkdir -p t @echo - @echo "${BLUE}=== Generating ${subst t/,,$@}MB of random data... ===${NC}" + @echo -e "${BLUE}=== Generating ${subst t/,,$@}MB of random data... ===${NC}" dd if=/dev/random of=$@ bs=1M count=${subst t/,,$@} status=progress - @echo "${BLUE}=== done ===${NC}" + @echo -e "${BLUE}=== done ===${NC}" @echo benchmarks.csv: md2 ${TESTFILES} diff --git a/Implementierung/src/io.c b/Implementierung/src/io.c index e0720a9..4312cd4 100644 --- a/Implementierung/src/io.c +++ b/Implementierung/src/io.c @@ -35,22 +35,21 @@ uint8_t* read_file(const char* path, size_t* size) { struct sysinfo info; int r = sysinfo(&info); - if (r != 0 || info.freeram < (unsigned long)(statOfFile.st_blksize * - statOfFile.st_blocks * 2)) { + + if (r != 0 || info.freeram < (unsigned long)(statOfFile.st_size * 2)) { errno = ENOMEM; return NULL; } - uint8_t* data = malloc(statOfFile.st_blksize * statOfFile.st_blocks); + uint8_t* data = malloc(statOfFile.st_size); if (data == NULL) { fclose(f); return NULL; } - size_t bytesRead = - fread(data, statOfFile.st_blksize, statOfFile.st_blocks, f); - // size_t bytesRead = fread(data, sizeof(uint8_t), statOfFile.st_size, f); - if (bytesRead != 0 && !feof(f)) { + fread(data, 1, statOfFile.st_size, f); + + if (ferror(f)) { fclose(f); if (errno == 0) errno = EIO; return NULL;