diff options
| author | Nakidai <nakidai@disroot.org> | 2025-03-31 17:05:36 +0300 |
|---|---|---|
| committer | Nakidai <nakidai@disroot.org> | 2025-03-31 17:05:36 +0300 |
| commit | 2abf5178e4957c18ee9f83490eff5e4135199ff1 (patch) | |
| tree | 1e618dbf7cdb8978c4d352dd2898e18f59430fef /allocfile.c | |
| parent | 9bf6d941428e9fd2ba84dd1ebf1a4f7abd7f5642 (diff) | |
| download | 3cl-2abf5178e4957c18ee9f83490eff5e4135199ff1.tar.gz 3cl-2abf5178e4957c18ee9f83490eff5e4135199ff1.zip | |
Some style improvments v1.3.1
- Rename readfile to allocfile (as it actually contains cccl_allocfile function) - Add cccl_ prefix for functions defined in str.c
Diffstat (limited to 'allocfile.c')
| -rw-r--r-- | allocfile.c | 19 |
1 files changed, 19 insertions, 0 deletions
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 <stdlib.h> + +#include <sys/stat.h> + + +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; +} |