diff options
Diffstat (limited to 'src/resources/resourcemanager.cpp')
-rw-r--r-- | src/resources/resourcemanager.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index 4f409431..e2839416 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -24,6 +24,7 @@ #include "resourcemanager.h" #include <cassert> +#include <sstream> #include <physfs.h> #include "image.h" @@ -292,16 +293,11 @@ ResourceManager::loadTextFile(const std::string &fileName) return lines; } - // Reallocate and include terminating 0 character - fileContents = (char*)realloc(fileContents, contentsLength + 1); - fileContents[contentsLength] = '\0'; + std::istringstream iss(std::string(fileContents, contentsLength)); - // Tokenize and add each line separately - char *line = strtok(fileContents, "\n"); - while (line != NULL) - { + std::string line; + while(getline(iss, line, '\n')) { lines.push_back(line); - line = strtok(NULL, "\n"); } free(fileContents); |