aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2009-07-07 16:51:33 +0000
committerWerner Koch <[email protected]>2009-07-07 16:51:33 +0000
commit44add1c310cd4a8523a11fdc481c8b1b39344ef3 (patch)
tree96b41e30e843ecc7a939b1fadeeaff06d0654fb0
parentRelease session_env. (diff)
downloadgnupg-44add1c310cd4a8523a11fdc481c8b1b39344ef3.tar.gz
gnupg-44add1c310cd4a8523a11fdc481c8b1b39344ef3.zip
Minor bug fixes.
Enhanced function docs.
Diffstat (limited to '')
-rw-r--r--jnlib/ChangeLog6
-rw-r--r--jnlib/dotlock.c6
-rw-r--r--jnlib/logging.c3
-rw-r--r--jnlib/stringhelp.c28
-rw-r--r--jnlib/strlist.c16
-rw-r--r--jnlib/utf8conv.c6
6 files changed, 46 insertions, 19 deletions
diff --git a/jnlib/ChangeLog b/jnlib/ChangeLog
index 5f00f8ebc..e70e70525 100644
--- a/jnlib/ChangeLog
+++ b/jnlib/ChangeLog
@@ -1,3 +1,9 @@
+2009-07-07 Werner Koch <[email protected]>
+
+ * stringhelp.c (make_filename_try): Use jnlib_malloc.
+
+ * dotlock.c (read_lockfile): Replace jnlib_xmalloc by jnlib_malloc.
+
2009-06-04 Werner Koch <[email protected]>
* mischelp.h: Include SUN_LEN etc also for W32.
diff --git a/jnlib/dotlock.c b/jnlib/dotlock.c
index 96041c0ce..260c0863d 100644
--- a/jnlib/dotlock.c
+++ b/jnlib/dotlock.c
@@ -598,7 +598,11 @@ read_lockfile (DOTLOCK h, int *same_node )
*same_node = 0;
expected_len = 10 + 1 + h->nodename_len + 1;
if ( expected_len >= sizeof buffer_space)
- buffer = jnlib_xmalloc (expected_len);
+ {
+ buffer = jnlib_malloc (expected_len);
+ if (!buffer)
+ return -1;
+ }
else
buffer = buffer_space;
diff --git a/jnlib/logging.c b/jnlib/logging.c
index 6267dc11c..028697b78 100644
--- a/jnlib/logging.c
+++ b/jnlib/logging.c
@@ -267,6 +267,9 @@ set_file_fd (const char *name, int fd)
/* Setup a new stream. */
#ifdef USE_FUNWRITER
+ /* The xmalloc below is justified because we can expect that this
+ function is called only during initialization and there is no
+ easy way out of this error condition. */
cookie = jnlib_xmalloc (sizeof *cookie + (name? strlen (name):0));
strcpy (cookie->name, name? name:"");
cookie->quiet = 0;
diff --git a/jnlib/stringhelp.c b/jnlib/stringhelp.c
index 3760c1db3..3ff743a08 100644
--- a/jnlib/stringhelp.c
+++ b/jnlib/stringhelp.c
@@ -252,9 +252,9 @@ length_sans_trailing_ws (const unsigned char *line, size_t len)
-/***************
- * Extract from a given path the filename component.
- *
+/*
+ * Extract from a given path the filename component. This function
+ * terminates the process on memory shortage.
*/
char *
make_basename(const char *filepath, const char *inputpath)
@@ -281,11 +281,10 @@ make_basename(const char *filepath, const char *inputpath)
-/***************
- * Extract from a given filename the path prepended to it.
- * If their isn't a path prepended to the filename, a dot
- * is returned ('.').
- *
+/*
+ * Extract from a given filename the path prepended to it. If there
+ * isn't a path prepended to the filename, a dot is returned ('.').
+ * This function terminates the process on memory shortage.
*/
char *
make_dirname(const char *filepath)
@@ -346,7 +345,8 @@ make_dirname(const char *filepath)
/* Construct a filename from the NULL terminated list of parts. Tilde
- expansion is done here. This function will never fail. */
+ expansion is done here. This function terminates the process on
+ memory shortage. */
char *
make_filename (const char *first_part, ... )
{
@@ -361,7 +361,7 @@ char *
make_filename_try (const char *first_part, ... )
{
MAKE_FILENAME_PART1
- name = jnlib_xmalloc (n);
+ name = jnlib_malloc (n);
if (!name)
return NULL;
MAKE_FILENAME_PART2
@@ -550,8 +550,9 @@ print_sanitized_utf8_string (FILE *fp, const char *string, int delim)
delim) : 0;
}
-/* Create a string from the buffer P_ARG of length N which is suitable for
- printing. Caller must release the created string using xfree. */
+/* Create a string from the buffer P_ARG of length N which is suitable
+ for printing. Caller must release the created string using xfree.
+ This function terminates the process on memory shortage. */
char *
sanitize_buffer (const void *p_arg, size_t n, int delim)
{
@@ -940,7 +941,8 @@ do_percent_escape (const char *str, const char *extra, int die)
}
/* Percent-escape the string STR by replacing colons with '%3a'. If
- EXTRA is not NULL all characters in EXTRA are also escaped. */
+ EXTRA is not NULL all characters in EXTRA are also escaped. This
+ function terminates the process on memory shortage. */
char *
percent_escape (const char *str, const char *extra)
{
diff --git a/jnlib/strlist.c b/jnlib/strlist.c
index 14506930b..d45a1648a 100644
--- a/jnlib/strlist.c
+++ b/jnlib/strlist.c
@@ -41,6 +41,8 @@ free_strlist( strlist_t sl )
}
+/* Add STRING to the LIST at the front. This function terminates the
+ process on memory shortage. */
strlist_t
add_to_strlist( strlist_t *list, const char *string )
{
@@ -55,8 +57,9 @@ add_to_strlist( 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. */
+/* 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 )
@@ -75,6 +78,9 @@ add_to_strlist2( strlist_t *list, const char *string, int is_utf8 )
}
#endif /* JNLIB_NEED_UTF8CONV*/
+
+/* Add STRING to the LIST at the end. This function terminates the
+ process on memory shortage. */
strlist_t
append_to_strlist( strlist_t *list, const char *string )
{
@@ -114,7 +120,8 @@ append_to_strlist2( strlist_t *list, const char *string, int is_utf8 )
#endif /* JNLIB_NEED_UTF8CONV */
-/* Return a copy of LIST. */
+/* Return a copy of LIST. This function terminates the process on
+ memory shortage.*/
strlist_t
strlist_copy (strlist_t list)
{
@@ -155,6 +162,9 @@ strlist_last( strlist_t node )
}
+/* Remove the first item from LIST and return its content in an
+ allocated buffer. This function terminates the process on memory
+ shortage. */
char *
strlist_pop (strlist_t *list)
{
diff --git a/jnlib/utf8conv.c b/jnlib/utf8conv.c
index 5223d473b..fee4dc6a5 100644
--- a/jnlib/utf8conv.c
+++ b/jnlib/utf8conv.c
@@ -314,7 +314,8 @@ is_native_utf8 (void)
/* Convert string, which is in native encoding to UTF8 and return a
- new allocated UTF-8 string. */
+ new allocated UTF-8 string. This function terminates the process
+ on memory shortage. */
char *
native_to_utf8 (const char *orig_string)
{
@@ -682,7 +683,8 @@ do_utf8_to_native (const char *string, size_t length, int delim,
illegal encodings by some "\xnn" and quote all control
characters. A character with value DELIM will always be quoted, it
must be a vanilla ASCII character. A DELIM value of -1 is special:
- it disables all quoting of control characters. */
+ it disables all quoting of control characters. This function
+ terminates the process on memory shortage. */
char *
utf8_to_native (const char *string, size_t length, int delim)
{