diff options
author | Matthias Huetsch [mhu] <matthias.huetsch@sun.com> | 2010-03-04 15:19:41 +0100 |
---|---|---|
committer | Matthias Huetsch [mhu] <matthias.huetsch@sun.com> | 2010-03-04 15:19:41 +0100 |
commit | 709ee7e9b098fa7074d84d3faab7aa5cd5ebf73b (patch) | |
tree | d58e2e95e278a2c864877950904c7bc27dbe3e41 /registry/tools/regmerge.cxx | |
parent | ffca8743e16d5afd101df88aa50f2c8735830e53 (diff) |
mhu22: #i105430# #i108349# Fixed registry:ORegKey reference counting to avoid redundant closeKey()/flush() calls.
Diffstat (limited to 'registry/tools/regmerge.cxx')
-rw-r--r-- | registry/tools/regmerge.cxx | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/registry/tools/regmerge.cxx b/registry/tools/regmerge.cxx index 45cab0927b10..4fcb19a03c00 100644 --- a/registry/tools/regmerge.cxx +++ b/registry/tools/regmerge.cxx @@ -34,7 +34,7 @@ #include <stdio.h> #include <string.h> -#include "registry/registry.h" +#include "registry/registry.hxx" #include <rtl/ustring.hxx> #include <rtl/alloc.h> #include <osl/process.h> @@ -207,9 +207,7 @@ int main( int argc, char * argv[] ) int _cdecl main( int argc, char * argv[] ) #endif { - RegHandle hReg; - RegKeyHandle hRootKey; - bool bVerbose = checkCommandArgs(argc, argv); + bool bVerbose = checkCommandArgs(argc, argv); if (realargc < 4) { @@ -219,9 +217,11 @@ int _cdecl main( int argc, char * argv[] ) } ::rtl::OUString regName( convertToFileUrl(realargv[1]) ); - if (reg_openRegistry(regName.pData, &hReg, REG_READWRITE)) + + Registry reg; + if (reg.open(regName, REG_READWRITE) != REG_NO_ERROR) { - if (reg_createRegistry(regName.pData, &hReg)) + if (reg.create(regName) != REG_NO_ERROR) { if (bVerbose) fprintf(stderr, "open registry \"%s\" failed\n", realargv[1]); @@ -230,17 +230,16 @@ int _cdecl main( int argc, char * argv[] ) } } - if (!reg_openRootKey(hReg, &hRootKey)) + RegistryKey rootKey; + if (reg.openRootKey(rootKey) == REG_NO_ERROR) { ::rtl::OUString mergeKeyName( ::rtl::OUString::createFromAscii(realargv[2]) ); ::rtl::OUString targetRegName; for (int i = 3; i < realargc; i++) { targetRegName = convertToFileUrl(realargv[i]); - RegError _ret = reg_mergeKey( - hRootKey, mergeKeyName.pData, targetRegName.pData, sal_False, - bVerbose); - if (_ret) + RegError _ret = reg.mergeKey(rootKey, mergeKeyName, targetRegName, sal_False, bVerbose); + if (_ret != REG_NO_ERROR) { if (_ret == REG_MERGE_CONFLICT) { @@ -262,13 +261,7 @@ int _cdecl main( int argc, char * argv[] ) } } - if (reg_closeKey(hRootKey)) - { - if (bVerbose) - fprintf(stderr, "closing root key of registry \"%s\" failed\n", - realargv[1]); - exit(-3); - } + rootKey.releaseKey(); } else { if (bVerbose) @@ -277,7 +270,7 @@ int _cdecl main( int argc, char * argv[] ) exit(-4); } - if (reg_closeRegistry(hReg)) + if (reg.close() != REG_NO_ERROR) { if (bVerbose) fprintf(stderr, "closing registry \"%s\" failed\n", realargv[1]); |