Logo
Explore Help
Sign In
fbt/sbase
1
0
Fork 0
You've already forked sbase
Code Issues Pull Requests Releases Wiki Activity
Files
ac012408000e7f83831569b3f74c78b5c491a885
sbase/libutf/utftorunestr.c

14 lines
217 B
C
Raw Normal View History

Scrap chartorunearr(), introducing utftorunestr() 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.
2015-02-11 21:32:09 +01:00
/* 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;
}
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.24.6 Page: 26ms Template: 1ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API