1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-27 04:28:52 -05:00

Removed constant string length for monitor parameters.

This commit is contained in:
Marcel Metz 2011-10-03 13:54:05 -04:00
parent f89feefa46
commit 3aa4976d6f
4 changed files with 9 additions and 6 deletions

View File

@ -548,7 +548,6 @@ GLFWAPI void glfwSetErrorCallback(GLFWerrorfun cbfun);
#define GLFW_MONITOR_PARAM_I_PHYS_HEIGHT 2 #define GLFW_MONITOR_PARAM_I_PHYS_HEIGHT 2
#define GLFW_MONITOR_PARAM_I_SCREEN_X_POS 3 #define GLFW_MONITOR_PARAM_I_SCREEN_X_POS 3
#define GLFW_MONITOR_PARAM_I_SCREEN_Y_POS 4 #define GLFW_MONITOR_PARAM_I_SCREEN_Y_POS 4
#define GLFW_MONITOR_PARAM_S_NAME_LEN 30
/* Monitor types */ /* Monitor types */
typedef struct _GLFWmonitor* GLFWmonitor; typedef struct _GLFWmonitor* GLFWmonitor;

View File

@ -225,7 +225,7 @@ struct _GLFWmonitor
void* userPointer; void* userPointer;
char deviceName[GLFW_MONITOR_PARAM_S_NAME_LEN+1]; char* deviceName;
// physical dimensions in millimeters. // physical dimensions in millimeters.
int physicalWidth; int physicalWidth;
int physicalHeight; int physicalHeight;

View File

@ -52,8 +52,9 @@ _GLFWmonitor** _glfwCreateMonitor(_GLFWmonitor** current, DISPLAY_DEVICE* adapte
DeleteDC(dc); DeleteDC(dc);
memcpy((*current)->deviceName, monitor->DeviceName, GLFW_MONITOR_PARAM_S_NAME_LEN+1); (*monitor)->deviceName = _glfwMalloc(strlen(monitor->DeviceName) + 1);
(*current)->deviceName[GLFW_MONITOR_PARAM_S_NAME_LEN] = '\0'; memcpy((*current)->deviceName, monitor->DeviceName, strlen(monitor->DeviceName) + 1);
(*current)->deviceName[strlen(monitor->DeviceName)] = '\0';
(*current)->screenXPosition = setting->dmPosition.x; (*current)->screenXPosition = setting->dmPosition.x;
(*current)->screenYPosition = setting->dmPosition.y; (*current)->screenYPosition = setting->dmPosition.y;
@ -68,6 +69,7 @@ _GLFWmonitor* _glfwDestroyMonitor(_GLFWmonitor* monitor)
result = monitor->next; result = monitor->next;
_glfwFree(monitor->deviceName);
_glfwFree(monitor); _glfwFree(monitor);
return result; return result;

View File

@ -47,8 +47,9 @@ _GLFWmonitor** _glfwCreateMonitor(_GLFWmonitor** current, XRROutputInfo* outputI
(*current)->physicalWidth = outputInfo->mm_width; (*current)->physicalWidth = outputInfo->mm_width;
(*current)->physicalHeight = outputInfo->mm_height; (*current)->physicalHeight = outputInfo->mm_height;
memcpy((*current)->deviceName, outputInfo->name, GLFW_MONITOR_PARAM_S_NAME_LEN+1); (*monitor)->deviceName = _glfwMalloc(strlen(outputInfo->name) + 1);
(*current)->deviceName[GLFW_MONITOR_PARAM_S_NAME_LEN] = '\0'; memcpy((*current)->deviceName, outputInfo->name, strlen(outputInfo->name) + 1);
(*current)->deviceName[strlen(outputInfo->name)] = '\0';
(*current)->screenXPosition = crtcInfo->x; (*current)->screenXPosition = crtcInfo->x;
(*current)->screenYPosition = crtcInfo->y; (*current)->screenYPosition = crtcInfo->y;
@ -68,6 +69,7 @@ _GLFWmonitor* _glfwDestroyMonitor(_GLFWmonitor* monitor)
XRRFreeOutputInfo(monitor->X11.output); XRRFreeOutputInfo(monitor->X11.output);
#endif /*_GLFW_HAS_XRANDR*/ #endif /*_GLFW_HAS_XRANDR*/
_glfwFree(monitor->deviceName);
_glfwFree(monitor); _glfwFree(monitor);
return result; return result;