]> granicus.if.org Git - mutt/commitdiff
Add mutt_str_adjust ().
authorThomas Roessler <roessler@does-not-exist.org>
Mon, 22 May 2000 10:10:08 +0000 (10:10 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Mon, 22 May 2000 10:10:08 +0000 (10:10 +0000)
charset.c
lib.c
lib.h
protos.h

index 262ebcc79892b366b3b161074fcd191da6072a49..e98f49a3a7b31d2c9568b4542789e95418699b62 100644 (file)
--- a/charset.c
+++ b/charset.c
@@ -420,7 +420,7 @@ int mutt_convert_string (char **ps, const char *from, const char *to)
     safe_free ((void **) ps);
     *ps = buf;
     
-    safe_realloc ((void **) ps, strlen (*ps) + 1);     /* avoid copying */
+    mutt_str_adjust (ps);
     return 0;
   }
   else
diff --git a/lib.c b/lib.c
index 7e2466993989a34bf7e856d165c4fac5feae64fb..09566ae73822f34d6880ae8e51097a846c727d8b 100644 (file)
--- a/lib.c
+++ b/lib.c
@@ -149,6 +149,13 @@ void mutt_str_replace (char **p, const char *s)
   *p = safe_strdup (s);
 }
 
+void mutt_str_adjust (char **p)
+{
+  if (!p || !*p) return;
+  
+  safe_realloc (p, strlen (*p) + 1);
+}
+
 /* convert all characters in the string to lowercase */
 char *mutt_strlower (char *s)
 {
diff --git a/lib.h b/lib.h
index 8fb13d8ee038c5fa2ddc6f9c5761d9165dd18deb..217dcfa51594c86147111a64f319803515e0654a 100644 (file)
--- a/lib.h
+++ b/lib.h
@@ -121,6 +121,8 @@ void *safe_malloc (size_t);
 void mutt_nocurses_error (const char *, ...);
 void mutt_remove_trailing_ws (char *);
 void mutt_sanitize_filename (char *, short);
+void mutt_str_replace (char **p, const char *s);
+void mutt_str_adjust (char **p);
 void mutt_unlink (const char *);
 void safe_free (void **);
 void safe_realloc (void **, size_t);
index b988e6f0b4009212ea1beede64b6cad26bef0098..b2683deae126cbf97163f5025eaeeeab6dade7db 100644 (file)
--- a/protos.h
+++ b/protos.h
@@ -206,7 +206,6 @@ void mutt_shell_escape (void);
 void mutt_show_error (void);
 void mutt_signal_init (void);
 void mutt_stamp_attachment (BODY *a);
-void mutt_str_replace (char **p, const char *s);
 void mutt_tabs_to_spaces (char *);
 void mutt_tag_set_flag (int, int);
 void mutt_unblock_signals (void);