summary refs log tree commit diff
path: root/readfile.c
blob: d4d17f82cb10d73a7212563f8fff5836c9b18c3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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;
}