Browse Source

refactor: use spaces instead of tabs

master
Dnomd343 3 years ago
parent
commit
93ac8bc353
  1. 10
      src/common.c

10
src/common.c

@ -97,17 +97,17 @@ char* read_file(char *file_name) { // read file content
char *msg = (char*)malloc(strlen(msg_prefix) + strlen(file_name) + strlen(msg_suffix) + 1); char *msg = (char*)malloc(strlen(msg_prefix) + strlen(file_name) + strlen(msg_suffix) + 1);
strcpy(msg, msg_prefix); strcpy(msg, msg_prefix);
error_exit(strcat(strcat(msg, file_name), msg_suffix)); // merge error message error_exit(strcat(strcat(msg, file_name), msg_suffix)); // merge error message
} }
fseek(pfile, 0, SEEK_END); fseek(pfile, 0, SEEK_END);
long file_length = ftell(pfile); // get file length long file_length = ftell(pfile); // get file length
char *file_content = (char*)malloc(file_length + 1); // malloc new memory char *file_content = (char*)malloc(file_length + 1); // malloc new memory
if (file_content == NULL) { if (file_content == NULL) {
error_exit("no enough memory"); // file too large error_exit("no enough memory"); // file too large
} }
rewind(pfile); rewind(pfile);
fread(file_content, 1, file_length, pfile); // read file stream fread(file_content, 1, file_length, pfile); // read file stream
file_content[file_length] = '\0'; // set end flag file_content[file_length] = '\0'; // set end flag
fclose(pfile); fclose(pfile);
return file_content; return file_content;
} }

Loading…
Cancel
Save