]> git.lizzy.rs Git - plan9front.git/blobdiff - sys/src/libhtml/utils.c
nusbrc: add LG G5 for nusb/ether
[plan9front.git] / sys / src / libhtml / utils.c
old mode 100755 (executable)
new mode 100644 (file)
index 5998913..6b49209
@@ -328,9 +328,12 @@ _Strncmpci(Rune *s1, int n1, Rune *s2)
 Rune*
 _Strdup(Rune* s)
 {
+       Rune* ans;
        if(s == nil)
                return nil;
-       return _Strndup(s, runestrlen(s));
+       ans = _Strndup(s, runestrlen(s));
+       setmalloctag(ans, getcallerpc(&s));
+       return ans;
 }
 
 // emalloc and copy n chars of s (assume s is at least that long),
@@ -346,6 +349,7 @@ _Strndup(Rune* s, int n)
        ans = _newstr(n);
        memmove(ans, s, n*sizeof(Rune));
        ans[n] = 0;
+       setmalloctag(ans, getcallerpc(&s));
        return ans;
 }
 // emalloc enough room for n Runes, plus 1 null terminator.
@@ -353,7 +357,11 @@ _Strndup(Rune* s, int n)
 Rune*
 _newstr(int n)
 {
-       return (Rune*)emalloc((n+1)*sizeof(Rune));
+       Rune* ans;
+
+       ans = (Rune*)emalloc((n+1)*sizeof(Rune));
+       setmalloctag(ans, getcallerpc(&n));
+       return ans;
 }
 
 // emalloc and copy s+t
@@ -372,6 +380,7 @@ _Strdup2(Rune* s, Rune* t)
        p = _Stradd(ans, s, ns);
        p = _Stradd(p, t, nt);
        *p = 0;
+       setmalloctag(ans, getcallerpc(&s));
        return ans;
 }
 
@@ -384,6 +393,7 @@ _Strsubstr(Rune* s, int start, int stop)
        if(start == stop)
                return nil;
        t = _Strndup(s+start, stop-start);
+       setmalloctag(t, getcallerpc(&s));
        return t;
 }
 
@@ -530,12 +540,13 @@ toStr(uchar* buf, int n, int chset)
                ans = nil;
                assert(0);
        }
+       setmalloctag(ans, getcallerpc(&buf));
        return ans;
 }
 
 // Convert buf[0:n], Unicode characters,
 // into an emalloc'd null-terminated string in character set chset.
-// Use 0x80 for unconvertable characters.
+// Use Runeerror for unconvertable characters.
 uchar*
 fromStr(Rune* buf, int n, int chset)
 {
@@ -554,7 +565,7 @@ fromStr(Rune* buf, int n, int chset)
                for(i = 0; i < n; i++) {
                        ch = buf[i];
                        if(ch > lim)
-                               ch = 0x80;
+                               ch = Runeerror;
                        ans[i] = ch;
                }
                ans[n] = 0;
@@ -575,6 +586,6 @@ fromStr(Rune* buf, int n, int chset)
        default:
                assert(0);
        }
+       setmalloctag(ans, getcallerpc(&buf));
        return ans;
-
 }