aboutsummaryrefslogtreecommitdiffstats
path: root/common/w32-reg.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2015-04-24 13:19:10 +0000
committerWerner Koch <[email protected]>2015-04-24 13:19:10 +0000
commit17bcd087082d01c48c60ff20d7f9a40f34c6969f (patch)
tree0fe57bea4c9827cd9bd6b49562c68b36c7046a02 /common/w32-reg.c
parentgpg: Move all DNS access to Dirmngr. (diff)
downloadgnupg-17bcd087082d01c48c60ff20d7f9a40f34c6969f.tar.gz
gnupg-17bcd087082d01c48c60ff20d7f9a40f34c6969f.zip
common: Remove libjnlib-config.h (jnlib merge).
* common/libjnlib-config.h: Remove. * common/common-defs.h (getenv) [HAVE_GETENV]: New. From removed header. (getpid) [HAVE_W32CE_SYSTEM]: New. From removed header. * common/argparse.c: Include util.h and common-defs.h. Replace jnlib_ macro names for non-GNUPG builds by x* names. * common/dotlock.c: Ditto. * common/logging.c: Include util.h and common-defs.h. Replace jnlib_ symbol names by x* names. * common/strlist.c: Ditto. * common/utf8conv.c: Ditto. * common/w32-reg.c: Ditto. * common/mischelp.c: Ditto. Also remove _jnlib_free. * common/stringhelp.c: Ditto. (JNLIB_LOG_WITH_PREFIX): Do not depend on this macro. * common/logging.h (JNLIB_LOG_WITH_PREFIX): Do not depend on this macro. -- This is part 1 of the patches to merge the jnlib files into common/. It does not make much sense to keep jnlib/ files separate. They are not often use elsewhere and maintaining the complex marcos stuff is too troublesome for the future. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'common/w32-reg.c')
-rw-r--r--common/w32-reg.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/common/w32-reg.c b/common/w32-reg.c
index 250717791..6a2b2dd59 100644
--- a/common/w32-reg.c
+++ b/common/w32-reg.c
@@ -41,7 +41,8 @@
#endif
#include <windows.h>
-#include "libjnlib-config.h"
+#include "util.h"
+#include "common-defs.h"
#include "utf8conv.h"
#include "w32help.h"
@@ -95,17 +96,17 @@ read_w32_registry_string (const char *root, const char *dir, const char *name)
{
if (root)
{
- jnlib_free (wdir);
+ xfree (wdir);
return NULL; /* No need for a RegClose, so return immediately. */
}
/* It seems to be common practise to fall back to HKLM. */
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, wdir, 0, KEY_READ, &key_handle) )
{
- jnlib_free (wdir);
+ xfree (wdir);
return NULL; /* Still no need for a RegClose. */
}
}
- jnlib_free (wdir);
+ xfree (wdir);
if (name)
{
@@ -119,12 +120,12 @@ read_w32_registry_string (const char *root, const char *dir, const char *name)
nbytes = 2;
if (RegQueryValueEx (key_handle, wname, 0, NULL, NULL, &nbytes))
goto leave;
- result = jnlib_malloc ((n1=nbytes+2));
+ result = xtrymalloc ((n1=nbytes+2));
if (!result)
goto leave;
if (RegQueryValueEx (key_handle, wname, 0, &type, result, &n1))
{
- jnlib_free (result);
+ xfree (result);
result = NULL;
goto leave;
}
@@ -134,11 +135,11 @@ read_w32_registry_string (const char *root, const char *dir, const char *name)
{
wchar_t *tmp = (void*)result;
result = wchar_to_utf8 (tmp);
- jnlib_free (tmp);
+ xfree (tmp);
}
leave:
- jnlib_free (wname);
+ xfree (wname);
RegCloseKey (key_handle);
return result;
#else /*!HAVE_W32CE_SYSTEM*/
@@ -161,12 +162,12 @@ read_w32_registry_string (const char *root, const char *dir, const char *name)
nbytes = 1;
if (RegQueryValueEx( key_handle, name, 0, NULL, NULL, &nbytes ) )
goto leave;
- result = jnlib_malloc ((n1=nbytes+1));
+ result = xtrymalloc ((n1=nbytes+1));
if (!result)
goto leave;
if (RegQueryValueEx( key_handle, name, 0, &type, result, &n1 ))
{
- jnlib_free (result);
+ xfree (result);
result = NULL;
goto leave;
}
@@ -176,46 +177,46 @@ read_w32_registry_string (const char *root, const char *dir, const char *name)
char *tmp;
n1 += 1000;
- tmp = jnlib_malloc (n1+1);
+ tmp = xtrymalloc (n1+1);
if (!tmp)
goto leave;
nbytes = ExpandEnvironmentStrings (result, tmp, n1);
if (nbytes && nbytes > n1)
{
- jnlib_free (tmp);
+ xfree (tmp);
n1 = nbytes;
- tmp = jnlib_malloc (n1 + 1);
+ tmp = xtrymalloc (n1 + 1);
if (!tmp)
goto leave;
nbytes = ExpandEnvironmentStrings (result, tmp, n1);
if (nbytes && nbytes > n1)
{
/* Oops - truncated, better don't expand at all. */
- jnlib_free (tmp);
+ xfree (tmp);
goto leave;
}
tmp[nbytes] = 0;
- jnlib_free (result);
+ xfree (result);
result = tmp;
}
else if (nbytes)
{
/* Okay, reduce the length. */
tmp[nbytes] = 0;
- jnlib_free (result);
- result = jnlib_malloc (strlen (tmp)+1);
+ xfree (result);
+ result = xtrymalloc (strlen (tmp)+1);
if (!result)
result = tmp;
else
{
strcpy (result, tmp);
- jnlib_free (tmp);
+ xfree (tmp);
}
}
else
{
/* Error - don't expand. */
- jnlib_free (tmp);
+ xfree (tmp);
}
}