fixed bad fread

lean v1.0.1
Avril 4 years ago
parent d4f6bd9b51
commit 15e093cae1
Signed by: flanchan
GPG Key ID: 284488987C31F630

3
.gitignore vendored

@ -1,3 +1,4 @@
*~
obj
build
build/
test/

@ -5,10 +5,12 @@ PROJECT=shuffle3
BUILD=build
OPT_FLAGS?= -march=native -fgraphite -fopenmp -floop-parallelize-all -ftree-parallelize-loops=4
CFLAGS+= $(addprefix -I,$(INCLUDE)) -Wall -pedantic --std=gnu11
LDFLAGS+= -lm
RELEASE_CFLAGS?= -O3 -march=native -flto -fgraphite
RELEASE_CFLAGS?= -O3 -flto $(OPT_FLAGS)
RELEASE_LDFLAGS?= -O3 -flto
DEBUG_CFLAGS?= -g -O0

@ -2,6 +2,7 @@
#include <float.h>
#include <stdint.h>
#include <string.h>
#include <assert.h>
#include <rng.h>
#include <rng_algos.h>
@ -194,7 +195,14 @@ array_t read_whole_file(S_NAMED_LEXENV(base), FILE* fp)
array_t ar;
MANAGED({
void* buf = smalloc(sz);
fread(buf, 1, sz, fp);
register size_t read;
register size_t full=0;
while ((read=fread(buf, 1, sz-full, fp))>0)
full+=read;
assert(full == sz);
ar = ar_create_memory_from(base, buf, 1, sz);
});
return ar;

Loading…
Cancel
Save