- [FIX] No estava tancant ningun arxiu, que peiv
This commit is contained in:
5
main.cpp
5
main.cpp
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user