ref: dd283bcfdcb1eee83e76228d5818d1ad031adf17
parent: 774256d67cbbcf1f10bb3cf2ab555b15aa02f2ff
parent: 2aa165bd3b584768cd99c838ea07098a55ec2007
author: Mike Swanson <mikeonthecomputer@gmail.com>
date: Fri Jun 1 11:46:15 EDT 2018
Merge remote-tracking branch 'turol/const'
--- a/src/d_iwad.c
+++ b/src/d_iwad.c
@@ -504,7 +504,7 @@
// Search a directory to try to find an IWAD
// Returns the location of the IWAD if found, otherwise NULL.
-static char *SearchDirectoryForIWAD(char *dir, int mask, GameMission_t *mission)
+static char *SearchDirectoryForIWAD(const char *dir, int mask, GameMission_t *mission)
{
char *filename;
size_t i;
@@ -571,14 +571,14 @@
// Add IWAD directories parsed from splitting a path string containing
// paths separated by PATH_SEPARATOR. 'suffix' is a string to concatenate
// to the end of the paths before adding them.
-static void AddIWADPath(char *path, char *suffix)
+static void AddIWADPath(const char *path, const char *suffix)
{
- char *left, *p;
+ char *left, *p, *dup_path;
- path = M_StringDuplicate(path);
+ dup_path = M_StringDuplicate(path);
// Split into individual dirs within the list.
- left = path;
+ left = dup_path;
for (;;)
{
@@ -600,7 +600,7 @@
AddIWADDir(M_StringJoin(left, suffix, NULL));
- free(path);
+ free(dup_path);
}
#ifndef _WIN32
@@ -890,7 +890,7 @@
// Get the IWAD name used for savegames.
//
-char *D_SaveGameIWADName(GameMission_t gamemission)
+const char *D_SaveGameIWADName(GameMission_t gamemission)
{
size_t i;
--- a/src/d_iwad.h
+++ b/src/d_iwad.h
@@ -43,7 +43,7 @@
char *D_TryFindWADByName(char *filename);
char *D_FindIWAD(int mask, GameMission_t *mission);
const iwad_t **D_FindAllIWADs(int mask);
-char *D_SaveGameIWADName(GameMission_t gamemission);
+const char *D_SaveGameIWADName(GameMission_t gamemission);
char *D_SuggestIWADName(GameMission_t mission, GameMode_t mode);
char *D_SuggestGameName(GameMission_t mission, GameMode_t mode);
void D_CheckCorrectIWAD(GameMission_t mission);
--- a/src/d_loop.c
+++ b/src/d_loop.c
@@ -823,7 +823,7 @@
// this extension (no extensions are allowed if -strictdemos is given
// on the command line). A warning is shown on the console using the
// provided string describing the non-vanilla expansion.
-boolean D_NonVanillaRecord(boolean conditional, char *feature)
+boolean D_NonVanillaRecord(boolean conditional, const char *feature)
{
if (!conditional || StrictDemos())
{
@@ -861,7 +861,7 @@
// demo that comes from a .lmp file, not a .wad file.
// - Before proceeding, a warning is shown to the user on the console.
boolean D_NonVanillaPlayback(boolean conditional, int lumpnum,
- char *feature)
+ const char *feature)
{
if (!conditional || StrictDemos())
{
--- a/src/d_loop.h
+++ b/src/d_loop.h
@@ -78,11 +78,11 @@
extern int gametic, ticdup;
// Check if it is permitted to record a demo with a non-vanilla feature.
-boolean D_NonVanillaRecord(boolean conditional, char *feature);
+boolean D_NonVanillaRecord(boolean conditional, const char *feature);
// Check if it is permitted to play back a demo with a non-vanilla feature.
boolean D_NonVanillaPlayback(boolean conditional, int lumpnum,
- char *feature);
+ const char *feature);
#endif
--- a/src/i_sound.h
+++ b/src/i_sound.h
@@ -74,7 +74,7 @@
typedef struct
{
// up to 6-character name
- char *name;
+ const char *name;
// lump number of music
int lumpnum;
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -55,7 +55,7 @@
// Window title
-static char *window_title = "";
+static const char *window_title = "";
// These are (1) the 320x200x8 paletted buffer that we draw to (i.e. the one
// that holds I_VideoBuffer), (2) the 320x200x32 RGBA intermediate buffer that
@@ -862,7 +862,7 @@
// Set the window title
//
-void I_SetWindowTitle(char *title)
+void I_SetWindowTitle(const char *title)
{
window_title = title;
}
--- a/src/i_video.h
+++ b/src/i_video.h
@@ -53,7 +53,7 @@
void I_BeginRead (void);
-void I_SetWindowTitle(char *title);
+void I_SetWindowTitle(const char *title);
void I_CheckIsScreensaver(void);
void I_SetGrabMouseCallback(grabmouse_callback_t func);
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -48,8 +48,8 @@
// Default filenames for configuration files.
-static char *default_main_config;
-static char *default_extra_config;
+static const char *default_main_config;
+static const char *default_extra_config;
typedef enum
{
@@ -63,7 +63,7 @@
typedef struct
{
// Name of the variable
- char *name;
+ const char *name;
// Pointer to the location in memory of the variable
union {
@@ -95,7 +95,7 @@
{
default_t *defaults;
int numdefaults;
- char *filename;
+ const char *filename;
} default_collection_t;
#define CONFIG_VARIABLE_GENERIC(name, type) \
@@ -1660,7 +1660,7 @@
// Search a collection for a variable
-static default_t *SearchCollection(default_collection_t *collection, char *name)
+static default_t *SearchCollection(default_collection_t *collection, const char *name)
{
int i;
@@ -1811,7 +1811,7 @@
// Parses integer values in the configuration file
-static int ParseIntParameter(char *strparm)
+static int ParseIntParameter(const char *strparm)
{
int parm;
@@ -1823,7 +1823,7 @@
return parm;
}
-static void SetVariable(default_t *def, char *value)
+static void SetVariable(default_t *def, const char *value)
{
int intparm;
@@ -1929,7 +1929,7 @@
// Set the default filenames to use for configuration files.
-void M_SetConfigFilenames(char *main_config, char *extra_config)
+void M_SetConfigFilenames(const char *main_config, const char *extra_config)
{
default_main_config = main_config;
default_extra_config = extra_config;
@@ -1949,10 +1949,10 @@
// Save defaults to alternate filenames
//
-void M_SaveDefaultsAlternate(char *main, char *extra)
+void M_SaveDefaultsAlternate(const char *main, const char *extra)
{
- char *orig_main;
- char *orig_extra;
+ const char *orig_main;
+ const char *orig_extra;
// Temporarily change the filenames
@@ -2030,7 +2030,7 @@
// Get a configuration file variable by its name
-static default_t *GetDefaultForName(char *name)
+static default_t *GetDefaultForName(const char *name)
{
default_t *result;
@@ -2057,7 +2057,7 @@
// Bind a variable to a given configuration file variable, by name.
//
-void M_BindIntVariable(char *name, int *location)
+void M_BindIntVariable(const char *name, int *location)
{
default_t *variable;
@@ -2070,7 +2070,7 @@
variable->bound = true;
}
-void M_BindFloatVariable(char *name, float *location)
+void M_BindFloatVariable(const char *name, float *location)
{
default_t *variable;
@@ -2081,7 +2081,7 @@
variable->bound = true;
}
-void M_BindStringVariable(char *name, char **location)
+void M_BindStringVariable(const char *name, char **location)
{
default_t *variable;
@@ -2095,7 +2095,7 @@
// Set the value of a particular variable; an API function for other
// parts of the program to assign values to config variables by name.
-boolean M_SetVariable(char *name, char *value)
+boolean M_SetVariable(const char *name, const char *value)
{
default_t *variable;
@@ -2113,7 +2113,7 @@
// Get the value of a variable.
-int M_GetIntVariable(char *name)
+int M_GetIntVariable(const char *name)
{
default_t *variable;
@@ -2128,7 +2128,7 @@
return *variable->location.i;
}
-const char *M_GetStringVariable(char *name)
+const char *M_GetStringVariable(const char *name)
{
default_t *variable;
@@ -2143,7 +2143,7 @@
return *variable->location.s;
}
-float M_GetFloatVariable(char *name)
+float M_GetFloatVariable(const char *name)
{
default_t *variable;
@@ -2213,7 +2213,7 @@
// Creates the directory as necessary.
//
-char *M_GetSaveGameDir(char *iwadname)
+char *M_GetSaveGameDir(const char *iwadname)
{
char *savegamedir;
char *topdir;
--- a/src/m_config.h
+++ b/src/m_config.h
@@ -24,17 +24,17 @@
void M_LoadDefaults(void);
void M_SaveDefaults(void);
-void M_SaveDefaultsAlternate(char *main, char *extra);
+void M_SaveDefaultsAlternate(const char *main, const char *extra);
void M_SetConfigDir(const char *dir);
-void M_BindIntVariable(char *name, int *variable);
-void M_BindFloatVariable(char *name, float *variable);
-void M_BindStringVariable(char *name, char **variable);
-boolean M_SetVariable(char *name, char *value);
-int M_GetIntVariable(char *name);
-const char *M_GetStringVariable(char *name);
-float M_GetFloatVariable(char *name);
-void M_SetConfigFilenames(char *main_config, char *extra_config);
-char *M_GetSaveGameDir(char *iwadname);
+void M_BindIntVariable(const char *name, int *variable);
+void M_BindFloatVariable(const char *name, float *variable);
+void M_BindStringVariable(const char *name, char **variable);
+boolean M_SetVariable(const char *name, const char *value);
+int M_GetIntVariable(const char *name);
+const char *M_GetStringVariable(const char *name);
+float M_GetFloatVariable(const char *name);
+void M_SetConfigFilenames(const char *main_config, const char *extra_config);
+char *M_GetSaveGameDir(const char *iwadname);
extern const char *configdir;
--- a/src/setup/multiplayer.c
+++ b/src/setup/multiplayer.c
@@ -67,7 +67,7 @@
// Filename to pass to '-iwad'.
-static char *iwadfile;
+static const char *iwadfile;
static const char *wad_extensions[] = { "wad", "lmp", "deh", NULL };