浏览代码

Some tweaks to LoadText()

pull/703/head
Ray 6 年前
父节点
当前提交
ab0287bd4e
共有 1 个文件被更改,包括 6 次插入9 次删除
  1. +6
    -9
      src/rlgl.h

+ 6
- 9
src/rlgl.h 查看文件

@ -2943,23 +2943,20 @@ char *LoadText(const char *fileName)
FILE *textFile; FILE *textFile;
char *text = NULL; char *text = NULL;
int count = 0;
if (fileName != NULL) if (fileName != NULL)
{ {
textFile = fopen(fileName,"rt");
textFile = fopen(fileName,"r");
if (textFile != NULL) if (textFile != NULL)
{ {
fseek(textFile, 0, SEEK_END); fseek(textFile, 0, SEEK_END);
n">count = ftell(textFile);
rewind(textFile);
kt">int size = ftell(textFile);
fseek(textFile, 0, SEEK_SET);
if (count > 0)
if (size > 0)
{ {
text = (char *)malloc(sizeof(char)*(count + 1));
count = fread(text, sizeof(char), count, textFile);
text[count] = '\0';
text = (char *)malloc(sizeof(char)*(size + 1));
fread(text, sizeof(char), size, textFile);
} }
fclose(textFile); fclose(textFile);

正在加载...
取消
保存