summaryrefslogtreecommitdiff
path: root/src/i_video.c
diff options
context:
space:
mode:
authorSimon Howard2014-03-30 18:07:52 -0400
committerSimon Howard2014-03-30 18:09:07 -0400
commit71d8ef248f4f1a05646f5e1e7e6388a59f08b121 (patch)
tree27aa543016b37eec74e99b49d309f235f6ecdc29 /src/i_video.c
parent724c4ad7a4f2a541eff157d9196b3835eb4bc8d8 (diff)
downloadchocolate-doom-71d8ef248f4f1a05646f5e1e7e6388a59f08b121.tar.gz
chocolate-doom-71d8ef248f4f1a05646f5e1e7e6388a59f08b121.tar.bz2
chocolate-doom-71d8ef248f4f1a05646f5e1e7e6388a59f08b121.zip
Eliminate some uses of sprintf() from common code.
As part of this, add DIR_SEPARATOR_S as a string version of the DIR_SEPARATOR macro. Change M_TempFile() to return a string allocated on the C heap rather than the zone heap. This is a first step towards fixing #371.
Diffstat (limited to 'src/i_video.c')
-rw-r--r--src/i_video.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/i_video.c b/src/i_video.c
index c129d143..823209b8 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -50,6 +50,7 @@
#include "i_scale.h"
#include "m_argv.h"
#include "m_config.h"
+#include "m_misc.h"
#include "tables.h"
#include "v_video.h"
#include "w_wad.h"
@@ -1224,13 +1225,9 @@ void I_InitWindowTitle(void)
{
char *buf;
- buf = Z_Malloc(strlen(window_title) + strlen(PACKAGE_STRING) + 5,
- PU_STATIC, NULL);
- sprintf(buf, "%s - %s", window_title, PACKAGE_STRING);
-
+ buf = M_StringJoin(window_title, " - ", PACKAGE_STRING, NULL);
SDL_WM_SetCaption(buf, NULL);
-
- Z_Free(buf);
+ free(buf);
}
// Set the application icon
@@ -1801,8 +1798,7 @@ static void SetSDLVideoDriver(void)
{
char *env_string;
- env_string = malloc(strlen(video_driver) + 30);
- sprintf(env_string, "SDL_VIDEODRIVER=%s", video_driver);
+ env_string = M_StringJoin("SDL_VIDEODRIVER=", video_driver, NULL);
putenv(env_string);
free(env_string);
}
@@ -1824,7 +1820,7 @@ static void SetWindowPositionVars(void)
}
else if (sscanf(window_position, "%i,%i", &x, &y) == 2)
{
- sprintf(buf, "SDL_VIDEO_WINDOW_POS=%i,%i", x, y);
+ snprintf(buf, sizeof(buf), "SDL_VIDEO_WINDOW_POS=%i,%i", x, y);
putenv(buf);
}
}
@@ -1994,7 +1990,7 @@ void I_InitGraphics(void)
int winid;
sscanf(env, "0x%x", &winid);
- sprintf(winenv, "SDL_WINDOWID=%i", winid);
+ snprintf(winenv, sizeof(winenv), "SDL_WINDOWID=%i", winid);
putenv(winenv);
}