mirror of
https://github.com/janet-lang/janet
synced 2025-07-06 20:12:53 +00:00
Address #35
This commit is contained in:
parent
17783c3c3e
commit
f161002390
@ -195,6 +195,9 @@ static Janet cfun_io_fread(int32_t argc, Janet *argv) {
|
|||||||
} else {
|
} else {
|
||||||
fseek(iof->file, 0, SEEK_END);
|
fseek(iof->file, 0, SEEK_END);
|
||||||
long fsize = ftell(iof->file);
|
long fsize = ftell(iof->file);
|
||||||
|
if (fsize < 0) {
|
||||||
|
janet_panicf("could not get file size of %v", argv[0]);
|
||||||
|
}
|
||||||
fseek(iof->file, 0, SEEK_SET);
|
fseek(iof->file, 0, SEEK_SET);
|
||||||
read_chunk(iof, buffer, (int32_t) fsize);
|
read_chunk(iof, buffer, (int32_t) fsize);
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,9 @@
|
|||||||
void *janet_memalloc_empty(int32_t count) {
|
void *janet_memalloc_empty(int32_t count) {
|
||||||
int32_t i;
|
int32_t i;
|
||||||
void *mem = malloc(count * sizeof(JanetKV));
|
void *mem = malloc(count * sizeof(JanetKV));
|
||||||
|
if (NULL == mem) {
|
||||||
|
JANET_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
JanetKV *mmem = (JanetKV *)mem;
|
JanetKV *mmem = (JanetKV *)mem;
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
JanetKV *kv = mmem + i;
|
JanetKV *kv = mmem + i;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user