From 2abf5178e4957c18ee9f83490eff5e4135199ff1 Mon Sep 17 00:00:00 2001 From: Nakidai Date: Mon, 31 Mar 2025 17:05:36 +0300 Subject: Some style improvments - Rename readfile to allocfile (as it actually contains cccl_allocfile function) - Add cccl_ prefix for functions defined in str.c --- allocfile.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 allocfile.c (limited to 'allocfile.c') diff --git a/allocfile.c b/allocfile.c new file mode 100644 index 0000000..d4d17f8 --- /dev/null +++ b/allocfile.c @@ -0,0 +1,19 @@ +#include "cccl.h" + +#include + +#include + + +int cccl_allocfile(const char *path, struct cccl_File *file) +{ + struct stat st; + int err = stat(path, &st); + if (err) + return err; + + file->size = st.st_size; + file->buffer = malloc(file->size); + + return !file->buffer; +} -- cgit 1.4.1