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),
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.
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
p = _Stradd(ans, s, ns);
p = _Stradd(p, t, nt);
*p = 0;
+ setmalloctag(ans, getcallerpc(&s));
return ans;
}
if(start == stop)
return nil;
t = _Strndup(s+start, stop-start);
+ setmalloctag(t, getcallerpc(&s));
return t;
}
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)
{
for(i = 0; i < n; i++) {
ch = buf[i];
if(ch > lim)
- ch = 0x80;
+ ch = Runeerror;
ans[i] = ch;
}
ans[n] = 0;
default:
assert(0);
}
+ setmalloctag(ans, getcallerpc(&buf));
return ans;
-
}