Add compat_strdup
This commit is contained in:
parent
d39276fe3a
commit
26e5104a96
|
@ -655,7 +655,7 @@ int fileNameListInit(const char* pattern, char*** fileNameListPtr, int a3, int a
|
||||||
char path[COMPAT_MAX_PATH];
|
char path[COMPAT_MAX_PATH];
|
||||||
sprintf(path, "%s%s", fileName, extension);
|
sprintf(path, "%s%s", fileName, extension);
|
||||||
free(xlist->fileNames[length]);
|
free(xlist->fileNames[length]);
|
||||||
xlist->fileNames[length] = strdup(path);
|
xlist->fileNames[length] = compat_strdup(path);
|
||||||
length++;
|
length++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,7 +141,7 @@ DBase* dbaseOpen(const char* filePath)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
dbase->path = strdup(filePath);
|
dbase->path = compat_strdup(filePath);
|
||||||
dbase->dataOffset = fileSize - dbaseDataSize;
|
dbase->dataOffset = fileSize - dbaseDataSize;
|
||||||
|
|
||||||
fclose(stream);
|
fclose(stream);
|
||||||
|
|
|
@ -230,7 +230,7 @@ int falloutMain(int argc, char** argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char* mapNameCopy = strdup(mapName != NULL ? mapName : _mainMap);
|
char* mapNameCopy = compat_strdup(mapName != NULL ? mapName : _mainMap);
|
||||||
_main_load_new(mapNameCopy);
|
_main_load_new(mapNameCopy);
|
||||||
free(mapNameCopy);
|
free(mapNameCopy);
|
||||||
|
|
||||||
|
|
|
@ -286,3 +286,8 @@ void compat_windows_path_to_native(char* path)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* compat_strdup(const char* string)
|
||||||
|
{
|
||||||
|
return SDL_strdup(string);
|
||||||
|
}
|
||||||
|
|
|
@ -39,5 +39,6 @@ gzFile compat_gzopen(const char* path, const char* mode);
|
||||||
int compat_remove(const char* path);
|
int compat_remove(const char* path);
|
||||||
int compat_rename(const char* oldFileName, const char* newFileName);
|
int compat_rename(const char* oldFileName, const char* newFileName);
|
||||||
void compat_windows_path_to_native(char* path);
|
void compat_windows_path_to_native(char* path);
|
||||||
|
char* compat_strdup(const char* string);
|
||||||
|
|
||||||
#endif /* PLATFORM_COMPAT_H */
|
#endif /* PLATFORM_COMPAT_H */
|
||||||
|
|
|
@ -512,7 +512,7 @@ bool xbaseOpen(const char* path)
|
||||||
|
|
||||||
memset(xbase, 0, sizeof(*xbase));
|
memset(xbase, 0, sizeof(*xbase));
|
||||||
|
|
||||||
xbase->path = strdup(path);
|
xbase->path = compat_strdup(path);
|
||||||
if (xbase->path == NULL) {
|
if (xbase->path == NULL) {
|
||||||
free(xbase);
|
free(xbase);
|
||||||
return false;
|
return false;
|
||||||
|
@ -814,7 +814,7 @@ static bool xlistEnumerateHandler(XListEnumerationContext* context)
|
||||||
|
|
||||||
xlist->fileNames = fileNames;
|
xlist->fileNames = fileNames;
|
||||||
|
|
||||||
fileNames[xlist->fileNamesLength] = strdup(context->name);
|
fileNames[xlist->fileNamesLength] = compat_strdup(context->name);
|
||||||
if (fileNames[xlist->fileNamesLength] == NULL) {
|
if (fileNames[xlist->fileNamesLength] == NULL) {
|
||||||
xlistFree(xlist);
|
xlistFree(xlist);
|
||||||
xlist->fileNamesLength = -1;
|
xlist->fileNamesLength = -1;
|
||||||
|
|
Loading…
Reference in New Issue