Kaydet (Commit) e3645fad authored tarafından Mathias Hasselmann's avatar Mathias Hasselmann Kaydeden (comit) Michael Meeks

evoab2: Avoid G_N_ELEMENTS when loading symbols

With G_N_ELEMENTS() the array name has to be twice, which can cause
hard to spot typos in code derived from copy-and-paste, as we have
here in the module loader. C++ can avoid the duplication by using
the proper templates.

Change-Id: I485e28a92e74b7e24f4a59cced6e5635f3a53a38
üst 213524cf
...@@ -95,10 +95,10 @@ static ApiMap aNewApiMap[] = ...@@ -95,10 +95,10 @@ static ApiMap aNewApiMap[] =
}; };
#undef SYM_MAP #undef SYM_MAP
static bool template<size_t N> static bool
tryLink( oslModule &aModule, const char *pName, ApiMap *pMap, guint nEntries ) tryLink( oslModule &aModule, const char *pName, const ApiMap (&pMap)[N])
{ {
for (guint i = 0; i < nEntries; ++i) for (guint i = 0; i < N; ++i)
{ {
SymbolFunc aMethod = (SymbolFunc)osl_getFunctionSymbol SymbolFunc aMethod = (SymbolFunc)osl_getFunctionSymbol
(aModule, OUString::createFromAscii ( pMap[ i ].sym_name ).pData); (aModule, OUString::createFromAscii ( pMap[ i ].sym_name ).pData);
...@@ -124,14 +124,14 @@ bool EApiInit() ...@@ -124,14 +124,14 @@ bool EApiInit()
SAL_LOADMODULE_DEFAULT ); SAL_LOADMODULE_DEFAULT );
if( aModule) if( aModule)
{ {
if (tryLink( aModule, eBookLibNames[ j ], aCommonApiMap, G_N_ELEMENTS(aCommonApiMap))) if (tryLink( aModule, eBookLibNames[ j ], aCommonApiMap))
{ {
if (eds_check_version(3, 6, 0) == NULL) if (eds_check_version(3, 6, 0) == NULL)
{ {
if (tryLink( aModule, eBookLibNames[ j ], aNewApiMap, G_N_ELEMENTS(aNewApiMap))) if (tryLink( aModule, eBookLibNames[ j ], aNewApiMap))
return true; return true;
} }
else if (tryLink( aModule, eBookLibNames[ j ], aOldApiMap, G_N_ELEMENTS(aOldApiMap))) else if (tryLink( aModule, eBookLibNames[ j ], aOldApiMap))
{ {
return true; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment