Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


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@openismus.com>


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.