[PATCH] Remove the weakly defined serverGeneration variable.
Jon TURNEY
jon.turney at dronecode.org.uk
Mon Jun 28 08:43:42 PDT 2010
Instead, since register_fpe_functions() is called by the xserver
on every generation, arrange for things which need to get reinitialized
for each server regeneration to do so then
Retain just-in-time initialization of that same data for other users
---
src/bitmap/bitscale.c | 16 +++++++++-------
src/fontfile/renderers.c | 25 ++++++++++++++++---------
src/util/miscutil.c | 12 +++++++++---
3 files changed, 34 insertions(+), 19 deletions(-)
diff --git a/src/bitmap/bitscale.c b/src/bitmap/bitscale.c
index a4d991d..24d6b1a 100644
--- a/src/bitmap/bitscale.c
+++ b/src/bitmap/bitscale.c
@@ -60,9 +60,6 @@ from The Open Group.
#define MAX(a,b) (((a)>(b)) ? a : b)
#endif
-/* Should get this from elsewhere */
-extern unsigned long serverGeneration;
-
static void bitmapUnloadScalable (FontPtr pFont);
static void ScaleBitmap ( FontPtr pFont, CharInfoPtr opci,
CharInfoPtr pci, double *inv_xform,
@@ -188,7 +185,7 @@ static fontProp rawFontPropTable[] = {
{ "RAW_X_HEIGHT", 0, }
};
-static void
+void
initFontPropTable(void)
{
int i;
@@ -598,10 +595,15 @@ ComputeScaledProperties(FontInfoPtr sourceFontInfo, /* the font to be scaled */
char *isStringProp;
int nProps;
- if (bitscaleGeneration != serverGeneration) {
- initFontPropTable();
- bitscaleGeneration = serverGeneration;
+ {
+ static Bool fontPropTableInitialized = FALSE;
+ if (!fontPropTableInitialized)
+ {
+ initFontPropTable();
+ fontPropTableInitialized = TRUE;
+ }
}
+
nProps = NPROPS + 1 + sizeof(fontPropTable) / sizeof(fontProp) +
sizeof(rawFontPropTable) / sizeof(fontProp);
fp = malloc(sizeof(FontPropRec) * nProps);
diff --git a/src/fontfile/renderers.c b/src/fontfile/renderers.c
index bf82c1c..3b10b4b 100644
--- a/src/fontfile/renderers.c
+++ b/src/fontfile/renderers.c
@@ -41,8 +41,14 @@ static FontRenderersRec renderers;
* XXX Maybe should allow unregistering renders. For now, just clear the
* list at each new generation.
*/
-extern unsigned long serverGeneration;
-static unsigned long rendererGeneration = 0;
+void
+FontFileInitRendererList(void)
+{
+ renderers.number = 0;
+ if (renderers.renderers)
+ free(renderers.renderers);
+ renderers.renderers = NULL;
+}
Bool
FontFileRegisterRenderer (FontRendererPtr renderer)
@@ -56,12 +62,14 @@ FontFilePriorityRegisterRenderer (FontRendererPtr renderer, int priority)
int i;
struct _FontRenderersElement *new;
- if (rendererGeneration != serverGeneration) {
- rendererGeneration = serverGeneration;
- renderers.number = 0;
- if (renderers.renderers)
- free(renderers.renderers);
- renderers.renderers = NULL;
+ {
+ static Bool renderListInitialized = FALSE;
+
+ if (!renderListInitialized)
+ {
+ FontFileInitRendererList();
+ renderListInitialized = TRUE;
+ }
}
for (i = 0; i < renderers.number; i++) {
@@ -69,7 +77,6 @@ FontFilePriorityRegisterRenderer (FontRendererPtr renderer, int priority)
renderer->fileSuffix)) {
if(renderers.renderers[i].priority >= priority) {
if(renderers.renderers[i].priority == priority) {
- if (rendererGeneration == 1)
ErrorF("Warning: font renderer for \"%s\" "
"already registered at priority %d\n",
renderer->fileSuffix, priority);
diff --git a/src/util/miscutil.c b/src/util/miscutil.c
index 1e76b4b..8ea1d9d 100644
--- a/src/util/miscutil.c
+++ b/src/util/miscutil.c
@@ -42,14 +42,17 @@ from The Open Group.
#ifdef __SUNPRO_C
-#pragma weak serverGeneration
#pragma weak register_fpe_functions
#endif
extern void BuiltinRegisterFpeFunctions(void);
-/* make sure everything initializes themselves at least once */
-weak long serverGeneration = 1;
+static void
+init_stuff(void)
+{
+ initFontPropTable();
+ FontFileInitRendererList();
+}
weak void
register_fpe_functions (void)
@@ -59,4 +62,7 @@ register_fpe_functions (void)
#ifdef XFONT_FC
fs_register_fpe_functions();
#endif
+
+ /* re-initialize things which need to get re-initialized for every server generation */
+ init_stuff();
}
--
1.7.0.4
--------------070302090607050800000906--
More information about the xorg-devel
mailing list