MCPcopy Create free account
hub / github.com/MegEngine/MegCC / read_file

Function read_file

runtime/example/standard_OS/lite_main.c:25–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23 }
24
25static void* read_file(const char* file_name) {
26 FILE* fin = fopen(file_name, "rb");
27 if (!fin) {
28 fprintf(stderr, "Open file error!!\n");
29 return NULL;
30 }
31 fseek(fin, 0, SEEK_END);
32 size_t size = ftell(fin);
33 fseek(fin, 0, SEEK_SET);
34 void* ptr = malloc(size);
35 size_t read_bytes = fread(ptr, 1, size, fin);
36 fclose(fin);
37 EXAMPLE_ASSERT(read_bytes == size);
38 return ptr;
39}
40
41static void write_file(const char* file_name, void* ptr, size_t length) {
42 FILE* fout = fopen(file_name, "wb");

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected