summaryrefslogtreecommitdiff
path: root/src/matfile.c
diff options
context:
space:
mode:
authorJacob McDonnell <jacob@jacobmcdonnell.com>2026-04-05 21:40:09 -0400
committerJacob McDonnell <jacob@jacobmcdonnell.com>2026-04-05 21:40:09 -0400
commit972845e2ecba5a46e33ad25934399d50bd63bdca (patch)
tree8c3345ce83dd920b1fde82cb5526dbddf09d94b9 /src/matfile.c
parent68eb1285777f3ee373b1e0e95771f21325659349 (diff)
feat: Function to write tags by themselvesHEADmain
Added a function to write tags by themselves as a shorthand since writing tags only is useful.
Diffstat (limited to 'src/matfile.c')
-rw-r--r--src/matfile.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/matfile.c b/src/matfile.c
index c6da630..85af901 100644
--- a/src/matfile.c
+++ b/src/matfile.c
@@ -32,8 +32,16 @@ bool write_header(FILE *file) {
return (status == sizeof(header));
}
+bool write_tag(FILE *file, mTag_t tag) {
+ if (file == NULL) {
+ return false;
+ }
+
+ return (fwrite((const void *)&tag, 1, sizeof(tag), file) == sizeof(tag));
+}
+
bool write_data(FILE *file, const mData_t data) {
- if (data.data == NULL) {
+ if (data.data == NULL || file == NULL) {
return false;
}
@@ -51,6 +59,10 @@ bool write_data(FILE *file, const mData_t data) {
}
bool write_small_data(FILE *file, const mSmallData_t data) {
+ if (file == NULL) {
+ return false;
+ }
+
const size_t w = fwrite((const void *)&data, 1, sizeof(data), file);
return (w == sizeof(data));