15 lines
372 B
C
15 lines
372 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
unsigned char* read_file_bytes(const char* path, int* out_size) {
|
|
FILE* f = fopen(path, "rb");
|
|
if (!f) return 0;
|
|
fseek(f, 0, SEEK_END);
|
|
*out_size = (int)ftell(f);
|
|
fseek(f, 0, SEEK_SET);
|
|
unsigned char* buf = (unsigned char*)malloc(*out_size);
|
|
fread(buf, 1, *out_size, f);
|
|
fclose(f);
|
|
return buf;
|
|
}
|