mirror of
git://git.suckless.org/sbase
synced 2024-12-22 23:13:44 +00:00
73577f10a0
Interface and function as proposed by cls. The reasoning behind this function is that cls expressed his interest to keep memory allocation out of libutf, which is a very good motive. This simplifies the function a lot and should also increase the speed a bit, but the most important factor here is that there's no malloc anywhere in libutf, making it a lot smaller and more robust with a smaller attack-surface. Look at the paste(1) and tr(1) changes for an idiomatic way to allocate the right amount of space for the Rune-array.
14 lines
217 B
C
14 lines
217 B
C
/* See LICENSE file for copyright and license details. */
|
|
#include "../utf.h"
|
|
|
|
int
|
|
utftorunestr(const char *str, Rune *r)
|
|
{
|
|
int i, n;
|
|
|
|
for(i = 0; (n = chartorune(&r[i], str)) && r[i]; i++)
|
|
str += n;
|
|
|
|
return i;
|
|
}
|