[svn] GnuPG - r5066 - trunk/jnlib

svn author wk cvs at cvs.gnupg.org
Tue Jul 7 18:51:34 CEST 2009


Author: wk
Date: 2009-07-07 18:51:33 +0200 (Tue, 07 Jul 2009)
New Revision: 5066

Modified:
   trunk/jnlib/ChangeLog
   trunk/jnlib/dotlock.c
   trunk/jnlib/logging.c
   trunk/jnlib/stringhelp.c
   trunk/jnlib/strlist.c
   trunk/jnlib/utf8conv.c
Log:
Minor bug fixes.
Enhanced function docs.


Modified: trunk/jnlib/ChangeLog
===================================================================
--- trunk/jnlib/ChangeLog	2009-07-07 10:29:52 UTC (rev 5065)
+++ trunk/jnlib/ChangeLog	2009-07-07 16:51:33 UTC (rev 5066)
@@ -1,3 +1,9 @@
+2009-07-07  Werner Koch  <wk at g10code.com>
+
+	* stringhelp.c (make_filename_try): Use jnlib_malloc.
+
+	* dotlock.c (read_lockfile): Replace jnlib_xmalloc by jnlib_malloc.
+
 2009-06-04  Werner Koch  <wk at g10code.com>
 
 	* mischelp.h: Include SUN_LEN etc also for W32.

Modified: trunk/jnlib/dotlock.c
===================================================================
--- trunk/jnlib/dotlock.c	2009-07-07 10:29:52 UTC (rev 5065)
+++ trunk/jnlib/dotlock.c	2009-07-07 16:51:33 UTC (rev 5066)
@@ -598,7 +598,11 @@
   *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;
 

Modified: trunk/jnlib/logging.c
===================================================================
--- trunk/jnlib/logging.c	2009-07-07 10:29:52 UTC (rev 5065)
+++ trunk/jnlib/logging.c	2009-07-07 16:51:33 UTC (rev 5066)
@@ -267,6 +267,9 @@
 
   /* 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;

Modified: trunk/jnlib/stringhelp.c
===================================================================
--- trunk/jnlib/stringhelp.c	2009-07-07 10:29:52 UTC (rev 5065)
+++ trunk/jnlib/stringhelp.c	2009-07-07 16:51:33 UTC (rev 5066)
@@ -252,9 +252,9 @@
 
 
 
-/***************
- * 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 @@
 
 
 
-/***************
- * 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 @@
 
 
 /* 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 @@
 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 @@
                                               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 @@
 }
 
 /* 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)
 {

Modified: trunk/jnlib/strlist.c
===================================================================
--- trunk/jnlib/strlist.c	2009-07-07 10:29:52 UTC (rev 5065)
+++ trunk/jnlib/strlist.c	2009-07-07 16:51:33 UTC (rev 5066)
@@ -41,6 +41,8 @@
 }
 
 
+/* 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 @@
 }
 
 
-/* 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 @@
 }
 #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 @@
 #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 @@
 }
 
 
+/* 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)
 {

Modified: trunk/jnlib/utf8conv.c
===================================================================
--- trunk/jnlib/utf8conv.c	2009-07-07 10:29:52 UTC (rev 5065)
+++ trunk/jnlib/utf8conv.c	2009-07-07 16:51:33 UTC (rev 5066)
@@ -314,7 +314,8 @@
 
 
 /* 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 @@
    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)
 {




More information about the Gnupg-commits mailing list