[PATCH 3/3] Make Xvfb independent of MAXSCREENS.
Jamey Sharp
jamey at minilop.net
Mon Apr 26 19:17:12 PDT 2010
If a -screen option specifies a screen number higher than any previously
specified, reallocate the vfb-private array of screen-info structs.
If built with a DIX that still has a MAXSCREENS limit, asking for too
many screens won't be detected until InitOutput calls AddScreen.
Signed-off-by: Jamey Sharp <jamey at minilop.net>
---
hw/vfb/InitOutput.c | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/hw/vfb/InitOutput.c b/hw/vfb/InitOutput.c
index f710828..2985787 100644
--- a/hw/vfb/InitOutput.c
+++ b/hw/vfb/InitOutput.c
@@ -104,7 +104,7 @@ typedef struct
} vfbScreenInfo, *vfbScreenInfoPtr;
static int vfbNumScreens;
-static vfbScreenInfo vfbScreens[MAXSCREENS];
+static vfbScreenInfo *vfbScreens;
static vfbScreenInfo defaultScreenInfo = {
.width = VFB_DEFAULT_WIDTH,
.height = VFB_DEFAULT_HEIGHT,
@@ -280,7 +280,7 @@ ddxProcessArgument(int argc, char *argv[], int i)
int screenNum;
CHECK_FOR_REQUIRED_ARGUMENTS(2);
screenNum = atoi(argv[i+1]);
- if (screenNum < 0 || screenNum >= MAXSCREENS)
+ if (screenNum < 0)
{
ErrorF("Invalid screen number %d\n", screenNum);
UseMsg();
@@ -288,8 +288,14 @@ ddxProcessArgument(int argc, char *argv[], int i)
screenNum);
}
- for (; vfbNumScreens <= screenNum; ++vfbNumScreens)
- vfbScreens[vfbNumScreens] = defaultScreenInfo;
+ if (vfbNumScreens <= screenNum)
+ {
+ vfbScreens = xrealloc(vfbScreens, sizeof(*vfbScreens) * (screenNum + 1));
+ if (!vfbScreens)
+ FatalError("Not enough memory for screen %d\n", screenNum);
+ for (; vfbNumScreens <= screenNum; ++vfbNumScreens)
+ vfbScreens[vfbNumScreens] = defaultScreenInfo;
+ }
if (3 != sscanf(argv[i+2], "%dx%dx%d",
&vfbScreens[screenNum].width,
@@ -953,7 +959,7 @@ InitOutput(ScreenInfo *screenInfo, int argc, char **argv)
if (vfbNumScreens < 1)
{
- vfbScreens[0] = defaultScreenInfo;
+ vfbScreens = &defaultScreenInfo;
vfbNumScreens = 1;
}
for (i = 0; i < vfbNumScreens; i++)
--
1.7.0
More information about the xorg-devel
mailing list