mirror of
https://github.com/glfw/glfw.git
synced 2024-11-25 19:42:00 +00:00
Replace sprintf with snprintf
This commit is contained in:
parent
9d42e146e7
commit
ea1958a948
@ -221,7 +221,7 @@ static const char* get_button_name(int button)
|
|||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
static char name[16];
|
static char name[16];
|
||||||
sprintf(name, "%i", button);
|
snprintf(name, sizeof(name), "%i", button);
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -555,7 +555,7 @@ int main(int argc, char** argv)
|
|||||||
slots[i].closeable = GLFW_TRUE;
|
slots[i].closeable = GLFW_TRUE;
|
||||||
slots[i].number = i + 1;
|
slots[i].number = i + 1;
|
||||||
|
|
||||||
sprintf(title, "Event Linter (Window %i)", slots[i].number);
|
snprintf(title, sizeof(title), "Event Linter (Window %i)", slots[i].number);
|
||||||
|
|
||||||
if (monitor)
|
if (monitor)
|
||||||
{
|
{
|
||||||
|
@ -59,13 +59,14 @@ static const char* format_mode(const GLFWvidmode* mode)
|
|||||||
static char buffer[512];
|
static char buffer[512];
|
||||||
const int gcd = euclid(mode->width, mode->height);
|
const int gcd = euclid(mode->width, mode->height);
|
||||||
|
|
||||||
sprintf(buffer,
|
snprintf(buffer,
|
||||||
"%i x %i x %i (%i:%i) (%i %i %i) %i Hz",
|
sizeof(buffer),
|
||||||
mode->width, mode->height,
|
"%i x %i x %i (%i:%i) (%i %i %i) %i Hz",
|
||||||
mode->redBits + mode->greenBits + mode->blueBits,
|
mode->width, mode->height,
|
||||||
mode->width / gcd, mode->height / gcd,
|
mode->redBits + mode->greenBits + mode->blueBits,
|
||||||
mode->redBits, mode->greenBits, mode->blueBits,
|
mode->width / gcd, mode->height / gcd,
|
||||||
mode->refreshRate);
|
mode->redBits, mode->greenBits, mode->blueBits,
|
||||||
|
mode->refreshRate);
|
||||||
|
|
||||||
buffer[sizeof(buffer) - 1] = '\0';
|
buffer[sizeof(buffer) - 1] = '\0';
|
||||||
return buffer;
|
return buffer;
|
||||||
|
@ -79,10 +79,10 @@ static void update_window_title(GLFWwindow* window)
|
|||||||
{
|
{
|
||||||
char title[256];
|
char title[256];
|
||||||
|
|
||||||
sprintf(title, "Tearing detector (interval %i%s, %0.1f Hz)",
|
snprintf(title, sizeof(title), "Tearing detector (interval %i%s, %0.1f Hz)",
|
||||||
swap_interval,
|
swap_interval,
|
||||||
(swap_tear && swap_interval < 0) ? " (swap tear)" : "",
|
(swap_tear && swap_interval < 0) ? " (swap tear)" : "",
|
||||||
frame_rate);
|
frame_rate);
|
||||||
|
|
||||||
glfwSetWindowTitle(window, title);
|
glfwSetWindowTitle(window, title);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user