REVIEWED: LoadText()
This commit is contained in:
parent
05992a6fce
commit
f2247c6f0a
1 changed files with 8 additions and 1 deletions
|
@ -3007,7 +3007,14 @@ char *LoadText(const char *fileName)
|
||||||
{
|
{
|
||||||
text = (char *)RL_MALLOC(sizeof(char)*(size + 1));
|
text = (char *)RL_MALLOC(sizeof(char)*(size + 1));
|
||||||
int count = fread(text, sizeof(char), size, textFile);
|
int count = fread(text, sizeof(char), size, textFile);
|
||||||
if (size == count) text[count] = '\0';
|
|
||||||
|
// WARNING: \r\n is converted to \n on reading, so,
|
||||||
|
// read bytes count gets reduced by the number of lines
|
||||||
|
if (count < size)
|
||||||
|
{
|
||||||
|
text = RL_REALLOC(text, count + 1);
|
||||||
|
text[count] = '\0';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(textFile);
|
fclose(textFile);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue