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 },
|
||||
#endif
|
||||
};
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(dmxExtensions); i++)
|
||||
LoadExtension(&dmxExtensions[i], TRUE);
|
||||
LoadExtensionList(dmxExtensions, ARRAY_SIZE(dmxExtensions), TRUE);
|
||||
}
|
||||
|
||||
/** This routine is called in Xserver/dix/main.c from \a main(). */
|
||||
|
|
|
@ -65,10 +65,7 @@ static const ExtensionModule ephyrExtensions[] = {
|
|||
static
|
||||
void ephyrExtensionInit(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(ephyrExtensions); i++)
|
||||
LoadExtension(&ephyrExtensions[i], TRUE);
|
||||
LoadExtensionList(ephyrExtensions, ARRAY_SIZE(ephyrExtensions), TRUE);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -892,10 +892,7 @@ static const ExtensionModule vfbExtensions[] = {
|
|||
static
|
||||
void vfbExtensionInit(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(vfbExtensions); i++)
|
||||
LoadExtension(&vfbExtensions[i], TRUE);
|
||||
LoadExtensionList(vfbExtensions, ARRAY_SIZE(vfbExtensions), TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -132,10 +132,7 @@ load_extension_config(void)
|
|||
void
|
||||
xf86ExtensionInit(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
load_extension_config();
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(extensionModules); i++)
|
||||
LoadExtension(&extensionModules[i], TRUE);
|
||||
LoadExtensionList(extensionModules, ARRAY_SIZE(extensionModules), TRUE);
|
||||
}
|
||||
|
|
|
@ -47,10 +47,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
|
||||
static MODULESETUPPROTO(glxSetup);
|
||||
|
||||
static const ExtensionModule GLXExt = {
|
||||
GlxExtensionInit,
|
||||
"GLX",
|
||||
&noGlxExtension
|
||||
static const ExtensionModule GLXExt[] = {
|
||||
{ GlxExtensionInit, "GLX", &noGlxExtension },
|
||||
};
|
||||
|
||||
static XF86ModuleVersionInfo VersRec = {
|
||||
|
@ -90,7 +88,7 @@ glxSetup(void *module, void *opts, int *errmaj, int *errmin)
|
|||
GlxPushProvider(provider);
|
||||
}
|
||||
|
||||
LoadExtension(&GLXExt, FALSE);
|
||||
LoadExtensionList(GLXExt, ARRAY_SIZE(GLXExt), FALSE);
|
||||
|
||||
return module;
|
||||
}
|
||||
|
|
|
@ -5920,10 +5920,10 @@ These may be moved out of the loader at some point.
|
|||
|
||||
<blockquote><para>
|
||||
<programlisting>
|
||||
void LoadExtension(ExtensionModule *ext);
|
||||
void LoadExtensionList(const ExtensionModule ext[]);
|
||||
</programlisting>
|
||||
<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
|
||||
defined as:
|
||||
|
||||
|
|
|
@ -164,10 +164,7 @@ static const ExtensionModule quartzExtensions[] = {
|
|||
*/
|
||||
static void QuartzExtensionInit(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(quartzExtensions); i++)
|
||||
LoadExtension(&quartzExtensions[i], TRUE);
|
||||
LoadExtensionList(quartzExtensions, ARRAY_SIZE(quartzExtensions), TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -163,8 +163,6 @@ static const ExtensionModule xwinExtensions[] = {
|
|||
static
|
||||
void XwinExtensionInit(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
#ifdef XWIN_GLX_WINDOWS
|
||||
if (g_fNativeGl) {
|
||||
/* install the native GL provider */
|
||||
|
@ -172,8 +170,7 @@ void XwinExtensionInit(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(xwinExtensions); i++)
|
||||
LoadExtension(&xwinExtensions[i], TRUE);
|
||||
LoadExtensionList(xwinExtensions, ARRAY_SIZE(xwinExtensions), TRUE);
|
||||
}
|
||||
|
||||
#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 LoadExtension(const ExtensionModule *ext, Bool external);
|
||||
extern _X_EXPORT void LoadExtensionList(const ExtensionModule ext[],
|
||||
int listSize, Bool external);
|
||||
|
||||
#endif /* EXTENSION_H */
|
||||
|
|
|
@ -312,15 +312,13 @@ static void
|
|||
AddStaticExtensions(void)
|
||||
{
|
||||
static Bool listInitialised = FALSE;
|
||||
int i;
|
||||
|
||||
if (listInitialised)
|
||||
return;
|
||||
listInitialised = TRUE;
|
||||
|
||||
/* Add built-in extensions to the list. */
|
||||
for (i = 0; i < ARRAY_SIZE(staticExtensions); i++)
|
||||
LoadExtension(&staticExtensions[i], TRUE);
|
||||
LoadExtensionList(staticExtensions, ARRAY_SIZE(staticExtensions), TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -341,7 +339,7 @@ InitExtensions(int argc, char *argv[])
|
|||
}
|
||||
|
||||
static ExtensionModule *
|
||||
NewExtensionModule(void)
|
||||
NewExtensionModuleList(int size)
|
||||
{
|
||||
ExtensionModule *save = ExtensionModuleList;
|
||||
int n;
|
||||
|
@ -350,7 +348,7 @@ NewExtensionModule(void)
|
|||
if (!ExtensionModuleList)
|
||||
numExtensionModules = 0;
|
||||
|
||||
n = numExtensionModules + 1;
|
||||
n = numExtensionModules + size;
|
||||
ExtensionModuleList = realloc(ExtensionModuleList,
|
||||
n * sizeof(ExtensionModule));
|
||||
if (ExtensionModuleList == NULL) {
|
||||
|
@ -358,29 +356,35 @@ NewExtensionModule(void)
|
|||
return NULL;
|
||||
}
|
||||
else {
|
||||
numExtensionModules++;
|
||||
return ExtensionModuleList + (numExtensionModules - 1);
|
||||
numExtensionModules += size;
|
||||
return ExtensionModuleList + (numExtensionModules - size);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
LoadExtension(const ExtensionModule * e, Bool builtin)
|
||||
LoadExtensionList(const ExtensionModule ext[], int size, Bool builtin)
|
||||
{
|
||||
ExtensionModule *newext;
|
||||
const char *msg;
|
||||
int i;
|
||||
|
||||
/* Make sure built-in extensions get added to the list before those
|
||||
* in modules. */
|
||||
AddStaticExtensions();
|
||||
|
||||
if (!(newext = NewExtensionModule()))
|
||||
if (!(newext = NewExtensionModuleList(size)))
|
||||
return;
|
||||
|
||||
if (builtin)
|
||||
ErrorF("Initializing built-in extension %s\n", e->name);
|
||||
msg = "Initializing built-in";
|
||||
else
|
||||
ErrorF("Loading extension %s\n", e->name);
|
||||
msg = "Loading";
|
||||
|
||||
newext->name = e->name;
|
||||
newext->initFunc = e->initFunc;
|
||||
newext->disablePtr = e->disablePtr;
|
||||
for (i = 0; i < size; i++, newext++) {
|
||||
ErrorF("%s extension %s\n", msg, ext[i].name);
|
||||
|
||||
newext->name = ext[i].name;
|
||||
newext->initFunc = ext[i].initFunc;
|
||||
newext->disablePtr = ext[i].disablePtr;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue