summaryrefslogtreecommitdiff
path: root/registry/tools/regview.cxx
diff options
context:
space:
mode:
authorMatthias Huetsch [mhu] <matthias.huetsch@oracle.com>2010-11-25 14:22:01 +0100
committerMatthias Huetsch [mhu] <matthias.huetsch@oracle.com>2010-11-25 14:22:01 +0100
commit0ff6b9a26dd3916e7e5f29f37ec2220b95bf5180 (patch)
tree024312450cda415f0eec0998c57219afe7bf6273 /registry/tools/regview.cxx
parentbb4f6eede90f866d878c6de2ebdb2a061686385c (diff)
#i115784# registry: fix memory errors uncovered by valgrind and other tools.
Diffstat (limited to 'registry/tools/regview.cxx')
-rw-r--r--registry/tools/regview.cxx72
1 files changed, 13 insertions, 59 deletions
diff --git a/registry/tools/regview.cxx b/registry/tools/regview.cxx
index 4e478e8985db..4c588449a1d8 100644
--- a/registry/tools/regview.cxx
+++ b/registry/tools/regview.cxx
@@ -28,65 +28,16 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_registry.hxx"
-#include <stdio.h>
-
#include "registry/registry.h"
-#include <rtl/ustring.hxx>
-#include <rtl/alloc.h>
-#include <osl/process.h>
-#include <osl/diagnose.h>
-#include <osl/thread.h>
-#include <osl/file.hxx>
-
-#ifdef SAL_UNX
-#define SEPARATOR '/'
-#else
-#define SEPARATOR '\\'
-#endif
-
-using namespace ::rtl;
-using namespace ::osl;
-
-sal_Bool isFileUrl(const OString& fileName)
-{
- if (fileName.indexOf("file://") == 0 )
- return sal_True;
- return sal_False;
-}
+#include "fileurl.hxx"
-OUString convertToFileUrl(const OString& fileName)
-{
- if ( isFileUrl(fileName) )
- {
- return OStringToOUString(fileName, osl_getThreadTextEncoding());
- }
+#include "rtl/ustring.hxx"
- OUString uUrlFileName;
- OUString uFileName(fileName.getStr(), fileName.getLength(), osl_getThreadTextEncoding());
- if ( fileName.indexOf('.') == 0 || fileName.indexOf(SEPARATOR) < 0 )
- {
- OUString uWorkingDir;
- if (osl_getProcessWorkingDir(&uWorkingDir.pData) != osl_Process_E_None)
- {
- OSL_ASSERT(false);
- }
- if (FileBase::getAbsoluteFileURL(uWorkingDir, uFileName, uUrlFileName)
- != FileBase::E_None)
- {
- OSL_ASSERT(false);
- }
- } else
- {
- if (FileBase::getFileURLFromSystemPath(uFileName, uUrlFileName)
- != FileBase::E_None)
- {
- OSL_ASSERT(false);
- }
- }
-
- return uUrlFileName;
-}
+#include <stdio.h>
+#include <string.h>
+using rtl::OUString;
+using namespace registry::tools;
#if (defined UNX) || (defined OS2)
int main( int argc, char * argv[] )
@@ -103,7 +54,7 @@ int _cdecl main( int argc, char * argv[] )
exit(1);
}
- OUString regName( convertToFileUrl(argv[1]) );
+ OUString regName( convertToFileUrl(argv[1], strlen(argv[1])) );
if (reg_openRegistry(regName.pData, &hReg, REG_READONLY))
{
fprintf(stderr, "open registry \"%s\" failed\n", argv[1]);
@@ -127,12 +78,14 @@ int _cdecl main( int argc, char * argv[] )
fprintf(stderr, "closing key \"%s\" of registry \"%s\" failed\n",
argv[2], argv[1]);
}
- } else
+ }
+ else
{
fprintf(stderr, "key \"%s\" not exists in registry \"%s\"\n",
argv[2], argv[1]);
}
- } else
+ }
+ else
{
if (reg_dumpRegistry(hRootKey))
{
@@ -144,7 +97,8 @@ int _cdecl main( int argc, char * argv[] )
{
fprintf(stderr, "closing root key of registry \"%s\" failed\n", argv[1]);
}
- } else
+ }
+ else
{
fprintf(stderr, "open root key of registry \"%s\" failed\n", argv[1]);
}