Add a buf1.closed field.

This commit is contained in:
Nigel Tao committed 2017-06-15 11:50:48 +10:00
1 parent 84e999c14e
commit b3c12e05cf
9 files changed
+44 -29

No files matched your search

+5
View File
@@ -54,6 +54,10 @@ bool read_file(puffs_base_buf1* dst, const char* path) {
FAIL("read_file: NULL argument");
return false;
}
if (dst->closed) {
FAIL("read_file: dst buffer closed for writes");
return false;
}
FILE* f = fopen(path, "r");
if (!f) {
FAIL("read_file(\"%s\"): %s (errno=%d)", path, strerror(errno), errno);
@@ -83,6 +87,7 @@ bool read_file(puffs_base_buf1* dst, const char* path) {
return false;
}
fclose(f);
dst->closed = true;
return true;
}