Commit 6828d8fc authored by Adam Jackson's avatar Adam Jackson 💣

Clean up DisplayModeRec handling in many places.

Use xf86DuplicateMode() instead of rolling our own, and change
malloc+memset to calloc.
parent 85617b56
......@@ -2088,8 +2088,7 @@ configMonitor(MonPtr monitorp, XF86ConfMonitorPtr conf_monitor)
*/
cmodep = conf_monitor->mon_modeline_lst;
while( cmodep ) {
mode = xnfalloc(sizeof(DisplayModeRec));
memset(mode,'\0',sizeof(DisplayModeRec));
mode = xnfcalloc(1, sizeof(DisplayModeRec));
mode->type = 0;
mode->Clock = cmodep->ml_clock;
mode->HDisplay = cmodep->ml_hdisplay;
......@@ -2426,10 +2425,7 @@ addDefaultModes(MonPtr monitorp)
if ( ! modeIsPresent(xf86DefaultModes[i].name,monitorp) )
do
{
mode = xnfalloc(sizeof(DisplayModeRec));
memcpy(mode,&xf86DefaultModes[i],sizeof(DisplayModeRec));
if (xf86DefaultModes[i].name)
mode->name = xnfstrdup(xf86DefaultModes[i].name);
mode = xf86DuplicateMode(&xf86DefaultModes[i]);
if( last ) {
mode->prev = last;
last->next = mode;
......
......@@ -56,7 +56,7 @@ _X_EXPORT DisplayModePtr
xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, Bool Reduced,
Bool Interlaced)
{
DisplayModeRec *Mode = xnfalloc(sizeof(DisplayModeRec));
DisplayModeRec *Mode = xnfcalloc(1, sizeof(DisplayModeRec));
/* 1) top/bottom margin size (% of height) - default: 1.8 */
#define CVT_MARGIN_PERCENTAGE 1.8
......@@ -79,8 +79,6 @@ xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, Bool Reduced,
int VDisplayRnd, VMargin, VSync;
float Interlace; /* Please rename this */
memset(Mode, 0, sizeof(DisplayModeRec));
/* CVT default is 60.0Hz */
if (!VRefresh)
VRefresh = 60.0;
......
......@@ -625,14 +625,11 @@ fbdevHWSetVideoModes(ScrnInfoPtr pScrn)
pScrn->virtualY = mode->VDisplay;
if (NULL == pScrn->modes) {
pScrn->modes = xnfalloc(sizeof(DisplayModeRec));
this = pScrn->modes;
memcpy(this,mode,sizeof(DisplayModeRec));
this = pScrn->modes = xf86DuplicateMode(mode);
this->next = this;
this->prev = this;
} else {
this = xnfalloc(sizeof(DisplayModeRec));
memcpy(this,mode,sizeof(DisplayModeRec));
this = xf86DuplicateMode(mode);
this->next = pScrn->modes;
this->prev = last;
last->next = this;
......
......@@ -336,8 +336,7 @@ DDCModeFromDetailedTiming(int scrnIndex, struct detailed_timings *timing,
" sync.\n", __func__, timing->h_active, timing->v_active);
}
Mode = xnfalloc(sizeof(DisplayModeRec));
memset(Mode, 0, sizeof(DisplayModeRec));
Mode = xnfcalloc(1, sizeof(DisplayModeRec));
Mode->type = M_T_DRIVER;
if (preferred)
......
......@@ -72,7 +72,7 @@ _X_EXPORT DisplayModePtr
xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, Bool Reduced,
Bool Interlaced)
{
DisplayModeRec *Mode = xnfalloc(sizeof(DisplayModeRec));
DisplayModeRec *Mode = xnfcalloc(1, sizeof(DisplayModeRec));
/* 1) top/bottom margin size (% of height) - default: 1.8 */
#define CVT_MARGIN_PERCENTAGE 1.8
......@@ -95,8 +95,6 @@ xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, Bool Reduced,
int VDisplayRnd, VMargin, VSync;
float Interlace; /* Please rename this */
memset(Mode, 0, sizeof(DisplayModeRec));
/* CVT default is 60.0Hz */
if (!VRefresh)
VRefresh = 60.0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment