]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add switch_toupper_max to uppercase a string 4 bytes at a time with new switch_touppe...
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 12 Dec 2012 02:12:25 +0000 (20:12 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 12 Dec 2012 02:12:25 +0000 (20:12 -0600)
src/include/switch_utils.h

index 92618a81d505a607d5677472eff61827357e27ec..b23ebf54459e9b971206ad41f5e84600ded4ca7e 100644 (file)
@@ -51,6 +51,37 @@ static inline uint32_t switch_toupper(uint32_t eax)
     return eax - ebx;
 }
 
+
+static inline void switch_toupper_max(char *s)
+{   
+    uint32_t *b,*p;
+    char *c;
+    size_t l;
+    int div = 0, rem = 0;
+    int i;
+
+    l = strlen(s);
+    div = l / 4;
+    rem = l % 4;
+
+    p = (uint32_t *) s;
+
+    for (i = 0; i < div; i++) {
+        b = p;
+        *b = (uint32_t) switch_toupper(*b);
+        b++;
+        p++;
+    }
+
+    c = (char *)p;
+
+    for (i = 0; i < rem; i++) {
+        *c = (char) switch_toupper(*c);
+        c++;
+    }
+}
+
+
 SWITCH_DECLARE(int) old_switch_toupper(int c);
 SWITCH_DECLARE(int) switch_tolower(int c);
 SWITCH_DECLARE(int) switch_isalnum(int c);