miinitext: introduce LoadExtensionList() to replace over LoadExtension()
Looping around LoadExtension() meant that ExtensionModuleList was reallocated on every extension. Using LoadExtensionList() we pass an array thus the function can do the reallocation in one go, and then loop and setup the ExtensionModuleList. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Reviewed-by: Keith Packard <keithp@keithp.com> v2: Update ephyr [Keith Packard] v3: Eliminate const warnings in LoadExtensionList [Keith Packard] Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
parent
d415b9d69f
commit
e46820fb89
|
@ -597,10 +597,8 @@ static void dmxAddExtensions(Bool glxSupported)
|
||||||
{ GlxExtensionInit, "GLX", &glxSupported },
|
{ GlxExtensionInit, "GLX", &glxSupported },
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(dmxExtensions); i++)
|
LoadExtensionList(dmxExtensions, ARRAY_SIZE(dmxExtensions), TRUE);
|
||||||
LoadExtension(&dmxExtensions[i], TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This routine is called in Xserver/dix/main.c from \a main(). */
|
/** This routine is called in Xserver/dix/main.c from \a main(). */
|
||||||
|
|
|
@ -65,10 +65,7 @@ static const ExtensionModule ephyrExtensions[] = {
|
||||||
static
|
static
|
||||||
void ephyrExtensionInit(void)
|
void ephyrExtensionInit(void)
|
||||||
{
|
{
|
||||||
int i;
|
LoadExtensionList(ephyrExtensions, ARRAY_SIZE(ephyrExtensions), TRUE);
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(ephyrExtensions); i++)
|
|
||||||
LoadExtension(&ephyrExtensions[i], TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -892,10 +892,7 @@ static const ExtensionModule vfbExtensions[] = {
|
||||||
static
|
static
|
||||||
void vfbExtensionInit(void)
|
void vfbExtensionInit(void)
|
||||||
{
|
{
|
||||||
int i;
|
LoadExtensionList(vfbExtensions, ARRAY_SIZE(vfbExtensions), TRUE);
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(vfbExtensions); i++)
|
|
||||||
LoadExtension(&vfbExtensions[i], TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -132,10 +132,7 @@ load_extension_config(void)
|
||||||
void
|
void
|
||||||
xf86ExtensionInit(void)
|
xf86ExtensionInit(void)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
load_extension_config();
|
load_extension_config();
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(extensionModules); i++)
|
LoadExtensionList(extensionModules, ARRAY_SIZE(extensionModules), TRUE);
|
||||||
LoadExtension(&extensionModules[i], TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,10 +47,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
static MODULESETUPPROTO(glxSetup);
|
static MODULESETUPPROTO(glxSetup);
|
||||||
|
|
||||||
static const ExtensionModule GLXExt = {
|
static const ExtensionModule GLXExt[] = {
|
||||||
GlxExtensionInit,
|
{ GlxExtensionInit, "GLX", &noGlxExtension },
|
||||||
"GLX",
|
|
||||||
&noGlxExtension
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static XF86ModuleVersionInfo VersRec = {
|
static XF86ModuleVersionInfo VersRec = {
|
||||||
|
@ -90,7 +88,7 @@ glxSetup(void *module, void *opts, int *errmaj, int *errmin)
|
||||||
GlxPushProvider(provider);
|
GlxPushProvider(provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadExtension(&GLXExt, FALSE);
|
LoadExtensionList(GLXExt, ARRAY_SIZE(GLXExt), FALSE);
|
||||||
|
|
||||||
return module;
|
return module;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5920,10 +5920,10 @@ These may be moved out of the loader at some point.
|
||||||
|
|
||||||
<blockquote><para>
|
<blockquote><para>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
void LoadExtension(ExtensionModule *ext);
|
void LoadExtensionList(const ExtensionModule ext[]);
|
||||||
</programlisting>
|
</programlisting>
|
||||||
<blockquote><para>
|
<blockquote><para>
|
||||||
This registers the entry points for the extension identified by
|
This registers the entry points for the extension array identified by
|
||||||
<parameter>ext</parameter>. The <structname>ExtensionModule</structname> struct is
|
<parameter>ext</parameter>. The <structname>ExtensionModule</structname> struct is
|
||||||
defined as:
|
defined as:
|
||||||
|
|
||||||
|
|
|
@ -164,10 +164,7 @@ static const ExtensionModule quartzExtensions[] = {
|
||||||
*/
|
*/
|
||||||
static void QuartzExtensionInit(void)
|
static void QuartzExtensionInit(void)
|
||||||
{
|
{
|
||||||
int i;
|
LoadExtensionList(quartzExtensions, ARRAY_SIZE(quartzExtensions), TRUE);
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(quartzExtensions); i++)
|
|
||||||
LoadExtension(&quartzExtensions[i], TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -163,8 +163,6 @@ static const ExtensionModule xwinExtensions[] = {
|
||||||
static
|
static
|
||||||
void XwinExtensionInit(void)
|
void XwinExtensionInit(void)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
#ifdef XWIN_GLX_WINDOWS
|
#ifdef XWIN_GLX_WINDOWS
|
||||||
if (g_fNativeGl) {
|
if (g_fNativeGl) {
|
||||||
/* install the native GL provider */
|
/* install the native GL provider */
|
||||||
|
@ -172,8 +170,7 @@ void XwinExtensionInit(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(xwinExtensions); i++)
|
LoadExtensionList(xwinExtensions, ARRAY_SIZE(xwinExtensions), TRUE);
|
||||||
LoadExtension(&xwinExtensions[i], TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(DDXBEFORERESET)
|
#if defined(DDXBEFORERESET)
|
||||||
|
|
|
@ -97,6 +97,7 @@ extern _X_EXPORT void InitExtensions(int argc, char **argv);
|
||||||
|
|
||||||
extern _X_EXPORT void CloseDownExtensions(void);
|
extern _X_EXPORT void CloseDownExtensions(void);
|
||||||
|
|
||||||
extern _X_EXPORT void LoadExtension(const ExtensionModule *ext, Bool external);
|
extern _X_EXPORT void LoadExtensionList(const ExtensionModule ext[],
|
||||||
|
int listSize, Bool external);
|
||||||
|
|
||||||
#endif /* EXTENSION_H */
|
#endif /* EXTENSION_H */
|
||||||
|
|
|
@ -312,15 +312,13 @@ static void
|
||||||
AddStaticExtensions(void)
|
AddStaticExtensions(void)
|
||||||
{
|
{
|
||||||
static Bool listInitialised = FALSE;
|
static Bool listInitialised = FALSE;
|
||||||
int i;
|
|
||||||
|
|
||||||
if (listInitialised)
|
if (listInitialised)
|
||||||
return;
|
return;
|
||||||
listInitialised = TRUE;
|
listInitialised = TRUE;
|
||||||
|
|
||||||
/* Add built-in extensions to the list. */
|
/* Add built-in extensions to the list. */
|
||||||
for (i = 0; i < ARRAY_SIZE(staticExtensions); i++)
|
LoadExtensionList(staticExtensions, ARRAY_SIZE(staticExtensions), TRUE);
|
||||||
LoadExtension(&staticExtensions[i], TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -341,7 +339,7 @@ InitExtensions(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
static ExtensionModule *
|
static ExtensionModule *
|
||||||
NewExtensionModule(void)
|
NewExtensionModuleList(int size)
|
||||||
{
|
{
|
||||||
ExtensionModule *save = ExtensionModuleList;
|
ExtensionModule *save = ExtensionModuleList;
|
||||||
int n;
|
int n;
|
||||||
|
@ -350,7 +348,7 @@ NewExtensionModule(void)
|
||||||
if (!ExtensionModuleList)
|
if (!ExtensionModuleList)
|
||||||
numExtensionModules = 0;
|
numExtensionModules = 0;
|
||||||
|
|
||||||
n = numExtensionModules + 1;
|
n = numExtensionModules + size;
|
||||||
ExtensionModuleList = realloc(ExtensionModuleList,
|
ExtensionModuleList = realloc(ExtensionModuleList,
|
||||||
n * sizeof(ExtensionModule));
|
n * sizeof(ExtensionModule));
|
||||||
if (ExtensionModuleList == NULL) {
|
if (ExtensionModuleList == NULL) {
|
||||||
|
@ -358,29 +356,35 @@ NewExtensionModule(void)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
numExtensionModules++;
|
numExtensionModules += size;
|
||||||
return ExtensionModuleList + (numExtensionModules - 1);
|
return ExtensionModuleList + (numExtensionModules - size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
LoadExtension(const ExtensionModule * e, Bool builtin)
|
LoadExtensionList(const ExtensionModule ext[], int size, Bool builtin)
|
||||||
{
|
{
|
||||||
ExtensionModule *newext;
|
ExtensionModule *newext;
|
||||||
|
const char *msg;
|
||||||
|
int i;
|
||||||
|
|
||||||
/* Make sure built-in extensions get added to the list before those
|
/* Make sure built-in extensions get added to the list before those
|
||||||
* in modules. */
|
* in modules. */
|
||||||
AddStaticExtensions();
|
AddStaticExtensions();
|
||||||
|
|
||||||
if (!(newext = NewExtensionModule()))
|
if (!(newext = NewExtensionModuleList(size)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (builtin)
|
if (builtin)
|
||||||
ErrorF("Initializing built-in extension %s\n", e->name);
|
msg = "Initializing built-in";
|
||||||
else
|
else
|
||||||
ErrorF("Loading extension %s\n", e->name);
|
msg = "Loading";
|
||||||
|
|
||||||
newext->name = e->name;
|
for (i = 0; i < size; i++, newext++) {
|
||||||
newext->initFunc = e->initFunc;
|
ErrorF("%s extension %s\n", msg, ext[i].name);
|
||||||
newext->disablePtr = e->disablePtr;
|
|
||||||
|
newext->name = ext[i].name;
|
||||||
|
newext->initFunc = ext[i].initFunc;
|
||||||
|
newext->disablePtr = ext[i].disablePtr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue