[PATCH] fix add default mode
Hong Liu
hong.liu at intel.com
Thu Mar 6 22:31:04 PST 2008
The build-in Modes don't have a name now
(after Adam's commit e65e51a99b17a0510782775f010e9820ca567fcb),
this may cause problem for code which uses the (name != NULL)
as a condition for termination of the xf86DefaultModes array.
Thanks,
Hong
diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 635a88c..1113acd 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -2420,12 +2420,12 @@ addDefaultModes(MonPtr monitorp)
DisplayModePtr last = monitorp->Last;
int i = 0;
- while (xf86DefaultModes[i].name != NULL)
+ while (xf86DefaultModes[i].Flags != 0)
{
- if ( ! modeIsPresent(xf86DefaultModes[i].name,monitorp) )
+ mode = xf86DuplicateMode(&xf86DefaultModes[i]);
+ if ( ! modeIsPresent(mode->name,monitorp) )
do
{
- mode = xf86DuplicateMode(&xf86DefaultModes[i]);
if( last ) {
mode->prev = last;
last->next = mode;
@@ -2438,10 +2438,14 @@ addDefaultModes(MonPtr monitorp)
last = mode;
i++;
}
- while((xf86DefaultModes[i].name != NULL) &&
- (!strcmp(xf86DefaultModes[i].name,xf86DefaultModes[i-1].name)));
+ while((xf86DefaultModes[i].Flags != 0) &&
+ (mode = xf86DuplicateMode(&xf86DefaultModes[i])) &&
+ (!strcmp(mode->name,last->name)));
else
i++;
+
+ xfree(mode->name);
+ xfree(mode);
}
monitorp->Last = last;
diff --git a/hw/xfree86/modes/xf86Modes.c b/hw/xfree86/modes/xf86Modes.c
index aa2635c..a2eb893 100644
--- a/hw/xfree86/modes/xf86Modes.c
+++ b/hw/xfree86/modes/xf86Modes.c
@@ -667,7 +667,7 @@ xf86GetDefaultModes (Bool interlaceAllowed, Bool doubleScanAllowed)
DisplayModePtr head = NULL, prev = NULL, mode;
int i;
- for (i = 0; xf86DefaultModes[i].name != NULL; i++)
+ for (i = 0; xf86DefaultModes[i].Flags != 0; i++)
{
DisplayModePtr defMode = &xf86DefaultModes[i];
@@ -676,17 +676,9 @@ xf86GetDefaultModes (Bool interlaceAllowed, Bool doubleScanAllowed)
if (!doubleScanAllowed && (defMode->Flags & V_DBLSCAN))
continue;
- mode = xalloc(sizeof(DisplayModeRec));
- if (!mode)
- continue;
- memcpy(mode,&xf86DefaultModes[i],sizeof(DisplayModeRec));
- mode->name = xstrdup(xf86DefaultModes[i].name);
- if (!mode->name)
- {
- xfree (mode);
- continue;
- }
- mode->prev = prev;
+ mode = xf86DuplicateMode(defMode);
+
+ mode->prev = prev;
mode->next = NULL;
if (prev)
prev->next = mode;
More information about the xorg
mailing list