From 972845e2ecba5a46e33ad25934399d50bd63bdca Mon Sep 17 00:00:00 2001 From: Jacob McDonnell Date: Sun, 5 Apr 2026 21:40:09 -0400 Subject: feat: Function to write tags by themselves Added a function to write tags by themselves as a shorthand since writing tags only is useful. --- src/matfile.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/matfile.c') 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)); -- cgit v1.2.3