Before, the function "getLevelFilenameFromBasename()" stored two
filenames in static string pointers, one for the level filename, and one
for the corresponding level template filename, because the results were
only used as references before. As they are now stored as string copies
outside if this function, it is sufficient to only store the last result.
This change is directly related to commit
759e0bea.
static char *getLevelFilenameFromBasename(char *basename)
{
- static char *filename[2] = { NULL, NULL };
- int pos = (strEqual(basename, LEVELTEMPLATE_FILENAME) ? 0 : 1);
+ static char *filename = NULL;
- checked_free(filename[pos]);
+ checked_free(filename);
- filename[pos] = getPath2(getCurrentLevelDir(), basename);
+ filename = getPath2(getCurrentLevelDir(), basename);
- return filename[pos];
+ return filename;
}
static int getFileTypeFromBasename(char *basename)