summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRay <[email protected]>2018-11-28 12:34:03 +0100
committerRay <[email protected]>2018-11-28 12:34:03 +0100
commitab0287bd4ed0e80afa8126d3e3960678ddad1c98 (patch)
tree00aa698a5af9b6a2c0b31be8eaf73068435f406c
parent0bf82ff6f4d0bf19b5c4ffe8e291d34903ef8f77 (diff)
downloadraylib-ab0287bd4ed0e80afa8126d3e3960678ddad1c98.tar.gz
raylib-ab0287bd4ed0e80afa8126d3e3960678ddad1c98.zip
Some tweaks to LoadText()
-rw-r--r--src/rlgl.h15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/rlgl.h b/src/rlgl.h
index 1308ad9d..18bbb7e1 100644
--- a/src/rlgl.h
+++ b/src/rlgl.h
@@ -2943,23 +2943,20 @@ char *LoadText(const char *fileName)
FILE *textFile;
char *text = NULL;
- int count = 0;
-
if (fileName != NULL)
{
- textFile = fopen(fileName,"rt");
+ textFile = fopen(fileName,"r");
if (textFile != NULL)
{
fseek(textFile, 0, SEEK_END);
- count = ftell(textFile);
- rewind(textFile);
+ 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);