- [FIX] No estava tancant ningun arxiu, que peiv

This commit is contained in:
2025-10-30 11:45:48 +01:00
parent 151c2d66b4
commit ea074c0f8a

View File

@@ -20,12 +20,17 @@ bool must_link = false;
char *getBufferFromFile(const char* filename) char *getBufferFromFile(const char* filename)
{ {
FILE *f = fopen(filename, "rb"); FILE *f = fopen(filename, "rb");
if (!f) {
perror("Error opening file");
exit(-1);
}
fseek(f, 0, SEEK_END); fseek(f, 0, SEEK_END);
long size = ftell(f); long size = ftell(f);
fseek(f, 0, SEEK_SET); fseek(f, 0, SEEK_SET);
char *buffer = (char*)malloc(size+1); char *buffer = (char*)malloc(size+1);
fread(buffer, size, 1, f); fread(buffer, size, 1, f);
buffer[size] = 0; buffer[size] = 0;
fclose(f);
return buffer; return buffer;
} }