From 17bcd087082d01c48c60ff20d7f9a40f34c6969f Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 24 Apr 2015 15:19:10 +0200 Subject: 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 --- common/w32-reg.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'common/w32-reg.c') 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 -#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); } } -- cgit v1.2.3