Add asserts
All checks were successful
CI / build-and-analyze (push) Successful in 1m9s

This commit is contained in:
2026-08-08 16:47:24 +03:00
parent ce2f70896e
commit 5a189f6f1d
3 changed files with 110 additions and 14 deletions

11
File.c
View File

@@ -1,8 +1,11 @@
#include "CgeFile.h"
#include <assert.h>
int CgeFileError(CgeFile *file) {
int flags;
assert(file != NULL);
CgeFileFlags(file, &flags);
return flags & CGE_FILE_ERROR;
}
@@ -10,6 +13,8 @@ int CgeFileError(CgeFile *file) {
int CgeFileEndOfFile(CgeFile *file) {
int flags;
assert(file != NULL);
CgeFileFlags(file, &flags);
return flags & CGE_FILE_EOF;
}
@@ -18,6 +23,9 @@ int CgeFilePeek(CgeFile *file, void *buffer, size_t size, size_t *actual) {
int64_t pos;
size_t n = 0;
assert(file != NULL);
assert(buffer != NULL);
if (CgeFileError(file) || CgeFileEndOfFile(file))
return 0;
@@ -26,6 +34,7 @@ int CgeFilePeek(CgeFile *file, void *buffer, size_t size, size_t *actual) {
!CgeFileSeek(file, pos, CGE_FILE_SET))
return 0;
if (actual) *actual = n;
if (actual)
*actual = n;
return 1;
}