[PATCH] evoab2: Avoid G_N_ELEMENTS when loading symbols
Mathias Hasselmann (via Code Review)
gerrit at gerrit.libreoffice.org
Fri Mar 8 05:03:52 PST 2013
Hi,
I have submitted a patch for review:
https://gerrit.libreoffice.org/2596
To pull it, you can do:
git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/96/2596/1
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
---
M connectivity/source/drivers/evoab2/EApi.cxx
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/connectivity/source/drivers/evoab2/EApi.cxx b/connectivity/source/drivers/evoab2/EApi.cxx
index 608b1f9..8e0d0db 100644
--- a/connectivity/source/drivers/evoab2/EApi.cxx
+++ b/connectivity/source/drivers/evoab2/EApi.cxx
@@ -95,10 +95,10 @@
};
#undef SYM_MAP
-static bool
-tryLink( oslModule &aModule, const char *pName, ApiMap *pMap, guint nEntries )
+template<size_t N> static bool
+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
(aModule, OUString::createFromAscii ( pMap[ i ].sym_name ).pData);
@@ -124,14 +124,14 @@
SAL_LOADMODULE_DEFAULT );
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 (tryLink( aModule, eBookLibNames[ j ], aNewApiMap, G_N_ELEMENTS(aNewApiMap)))
+ if (tryLink( aModule, eBookLibNames[ j ], aNewApiMap))
return true;
}
- else if (tryLink( aModule, eBookLibNames[ j ], aOldApiMap, G_N_ELEMENTS(aOldApiMap)))
+ else if (tryLink( aModule, eBookLibNames[ j ], aOldApiMap))
{
return true;
}
--
To view, visit https://gerrit.libreoffice.org/2596
To unsubscribe, visit https://gerrit.libreoffice.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I485e28a92e74b7e24f4a59cced6e5635f3a53a38
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Mathias Hasselmann <mathias at openismus.com>
More information about the LibreOffice
mailing list