use m_strdup and m_strlen that are inlined for efficiency
[apps/madmutt.git] / lib / str.c
index e40e614..7eb2efc 100644 (file)
--- a/lib/str.c
+++ b/lib/str.c
 #include <ctype.h>
 
 #include <lib-lib/mem.h>
+#include <lib-lib/str.h>
 
 #include "str.h"
 
-char *str_dup (const char *s)
-{
-  if (!s || !*s)
-      return NULL;
-  return p_dupstr(s, str_len(s));
-}
-
 char *str_cat (char *d, size_t l, const char *s)
 {
   char *p = d;
@@ -81,11 +75,6 @@ int str_ncasecmp (const char *a, const char *b, size_t l)
   return strncasecmp (NONULL (a), NONULL (b), l);
 }
 
-size_t str_len (const char *a)
-{
-  return a ? strlen (a) : 0;
-}
-
 int str_coll (const char *a, const char *b)
 {
   return strcoll (NONULL (a), NONULL (b));
@@ -94,14 +83,14 @@ int str_coll (const char *a, const char *b)
 void str_replace (char **p, const char *s)
 {
   p_delete(p);
-  *p = str_dup (s);
+  *p = m_strdup(s);
 }
 
 void str_adjust (char **p)
 {
   if (!p || !*p)
     return;
-  p_realloc(p, str_len (*p) + 1);
+  p_realloc(p, m_strlen(*p) + 1);
 }
 
 /* convert all characters in the string to lowercase */
@@ -159,9 +148,9 @@ const char *str_isstr (const char *haystack, const char *needle)
 }
 
 int str_eq (const char* s1, const char* s2) {
-  int l = str_len (s1);
+  int l = m_strlen(s1);
 
-  if (l != str_len (s2))
+  if (l != m_strlen(s2))
     return (0);
   return (str_ncmp (s1, s2, l) == 0);
 }
@@ -174,6 +163,6 @@ char* str_skip_initws (char* s) {
 void str_skip_trailws (char *s) {
   char *p;
 
-  for (p = s + str_len (s) - 1; p >= s && ISSPACE (*p); p--)
+  for (p = s + m_strlen(s) - 1; p >= s && ISSPACE (*p); p--)
     *p = 0;
 }