mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-26 15:53:44 +02:00
b2/subex.c (compose): use stralloc_n instead of open-coding its functionality
This commit is contained in:
parent
78bcb8d3de
commit
db279b7920
@ -92,7 +92,7 @@ static char *compose(const struct chunk *c,
|
||||
const char *s, const regmatch_t *match, const char *units)
|
||||
{
|
||||
char *res = stralloc("");
|
||||
int res_len = 0, len;
|
||||
int res_len = 0;
|
||||
const char *val;
|
||||
char *tmp, *tmp2;
|
||||
int n;
|
||||
@ -118,10 +118,8 @@ static char *compose(const struct chunk *c,
|
||||
}
|
||||
if (match[n].rm_so == -1)
|
||||
break;
|
||||
len = match[n].rm_eo-match[n].rm_so;
|
||||
tmp = alloc_size(len);
|
||||
memcpy(tmp, s+match[n].rm_so, len);
|
||||
tmp[len] = 0;
|
||||
tmp = stralloc_n(s+match[n].rm_so,
|
||||
match[n].rm_eo-match[n].rm_so);
|
||||
tmp2 = canonicalize(tmp, units ? units[n-1] : 0);
|
||||
append(&res, &res_len, tmp2);
|
||||
free(tmp);
|
||||
|
Loading…
Reference in New Issue
Block a user