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];
|
||||
sprintf(path, "%s%s", fileName, extension);
|
||||
free(xlist->fileNames[length]);
|
||||
xlist->fileNames[length] = strdup(path);
|
||||
xlist->fileNames[length] = compat_strdup(path);
|
||||
length++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ DBase* dbaseOpen(const char* filePath)
|
|||
goto err;
|
||||
}
|
||||
|
||||
dbase->path = strdup(filePath);
|
||||
dbase->path = compat_strdup(filePath);
|
||||
dbase->dataOffset = fileSize - dbaseDataSize;
|
||||
|
||||
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);
|
||||
free(mapNameCopy);
|
||||
|
||||
|
|
|
@ -286,3 +286,8 @@ void compat_windows_path_to_native(char* path)
|
|||
}
|
||||
#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_rename(const char* oldFileName, const char* newFileName);
|
||||
void compat_windows_path_to_native(char* path);
|
||||
char* compat_strdup(const char* string);
|
||||
|
||||
#endif /* PLATFORM_COMPAT_H */
|
||||
|
|
|
@ -512,7 +512,7 @@ bool xbaseOpen(const char* path)
|
|||
|
||||
memset(xbase, 0, sizeof(*xbase));
|
||||
|
||||
xbase->path = strdup(path);
|
||||
xbase->path = compat_strdup(path);
|
||||
if (xbase->path == NULL) {
|
||||
free(xbase);
|
||||
return false;
|
||||
|
@ -814,7 +814,7 @@ static bool xlistEnumerateHandler(XListEnumerationContext* context)
|
|||
|
||||
xlist->fileNames = fileNames;
|
||||
|
||||
fileNames[xlist->fileNamesLength] = strdup(context->name);
|
||||
fileNames[xlist->fileNamesLength] = compat_strdup(context->name);
|
||||
if (fileNames[xlist->fileNamesLength] == NULL) {
|
||||
xlistFree(xlist);
|
||||
xlist->fileNamesLength = -1;
|
||||
|
|
Loading…
Reference in New Issue