summaryrefslogtreecommitdiffstats
path: root/common/strlist.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2015-04-24 15:19:10 +0200
committerWerner Koch <wk@gnupg.org>2015-04-24 15:19:10 +0200
commit17bcd087082d01c48c60ff20d7f9a40f34c6969f (patch)
tree0fe57bea4c9827cd9bd6b49562c68b36c7046a02 /common/strlist.c
parentgpg: Move all DNS access to Dirmngr. (diff)
downloadgnupg2-17bcd087082d01c48c60ff20d7f9a40f34c6969f.tar.xz
gnupg2-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 <wk@gnupg.org>
Diffstat (limited to 'common/strlist.c')
-rw-r--r--common/strlist.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/common/strlist.c b/common/strlist.c
index 6816dcf1a..e29fd468e 100644
--- a/common/strlist.c
+++ b/common/strlist.c
@@ -35,11 +35,10 @@
#include <stdarg.h>
#include <ctype.h>
-#include "libjnlib-config.h"
+#include "util.h"
+#include "common-defs.h"
#include "strlist.h"
-#ifdef JNLIB_NEED_UTF8CONV
#include "utf8conv.h"
-#endif
void
free_strlist( strlist_t sl )
@@ -48,7 +47,7 @@ free_strlist( strlist_t sl )
for(; sl; sl = sl2 ) {
sl2 = sl->next;
- jnlib_free(sl);
+ xfree(sl);
}
}
@@ -60,7 +59,7 @@ add_to_strlist( strlist_t *list, const char *string )
{
strlist_t sl;
- sl = jnlib_xmalloc( sizeof *sl + strlen(string));
+ sl = xmalloc( sizeof *sl + strlen(string));
sl->flags = 0;
strcpy(sl->d, string);
sl->next = *list;
@@ -76,7 +75,7 @@ add_to_strlist_try (strlist_t *list, const char *string)
{
strlist_t sl;
- sl = jnlib_malloc (sizeof *sl + strlen (string));
+ sl = xtrymalloc (sizeof *sl + strlen (string));
if (sl)
{
sl->flags = 0;
@@ -91,7 +90,6 @@ add_to_strlist_try (strlist_t *list, const char *string)
/* Same as add_to_strlist() but if IS_UTF8 is *not* set, a conversion
to UTF-8 is done. This function terminates the process on memory
shortage. */
-#ifdef JNLIB_NEED_UTF8CONV
strlist_t
add_to_strlist2( strlist_t *list, const char *string, int is_utf8 )
{
@@ -103,11 +101,10 @@ add_to_strlist2( strlist_t *list, const char *string, int is_utf8 )
{
char *p = native_to_utf8( string );
sl = add_to_strlist( list, p );
- jnlib_free ( p );
+ xfree ( p );
}
return sl;
}
-#endif /* JNLIB_NEED_UTF8CONV*/
/* Add STRING to the LIST at the end. This function terminates the
@@ -117,7 +114,7 @@ append_to_strlist( strlist_t *list, const char *string )
{
strlist_t r, sl;
- sl = jnlib_xmalloc( sizeof *sl + strlen(string));
+ sl = xmalloc( sizeof *sl + strlen(string));
sl->flags = 0;
strcpy(sl->d, string);
sl->next = NULL;
@@ -132,7 +129,6 @@ append_to_strlist( strlist_t *list, const char *string )
}
-#ifdef JNLIB_NEED_UTF8CONV
strlist_t
append_to_strlist2( strlist_t *list, const char *string, int is_utf8 )
{
@@ -144,11 +140,10 @@ append_to_strlist2( strlist_t *list, const char *string, int is_utf8 )
{
char *p = native_to_utf8 (string);
sl = append_to_strlist( list, p );
- jnlib_free( p );
+ xfree( p );
}
return sl;
}
-#endif /* JNLIB_NEED_UTF8CONV */
/* Return a copy of LIST. This function terminates the process on
@@ -161,7 +156,7 @@ strlist_copy (strlist_t list)
last = &newlist;
for (; list; list = list->next)
{
- sl = jnlib_xmalloc (sizeof *sl + strlen (list->d));
+ sl = xmalloc (sizeof *sl + strlen (list->d));
sl->flags = list->flags;
strcpy(sl->d, list->d);
sl->next = NULL;
@@ -204,11 +199,11 @@ strlist_pop (strlist_t *list)
if(sl)
{
- str=jnlib_xmalloc(strlen(sl->d)+1);
+ str = xmalloc(strlen(sl->d)+1);
strcpy(str,sl->d);
*list=sl->next;
- jnlib_free(sl);
+ xfree(sl);
}
return str;