src/svf/svf_bison.y: Avoid calling strlen() multiple times on the same string. Fix by Frans Meulenbroeks.

git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1839 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Mike Frysinger 14 years ago
parent 95193fa86a
commit 328ca1d817

@ -14,6 +14,9 @@
* src/svf/svf_flex.l: Use memcpy() rather than strcpy() when we already know
the length and we just want to dupe the string.
* src/svf/svf_bison.y: Avoid calling strlen() multiple times on the same
string. Fix by Frans Meulenbroeks.
2010-08-26 Mike Frysinger <vapier@gentoo.org>
* src/tap/cable/gpio.c: Rewrite to use raw file descriptors when working with

@ -303,7 +303,8 @@ hexa_num_sequence
| hexa_num_sequence HEXA_NUM_FRAGMENT
{
#define REALLOC_STEP (1 << 16)
size_t req_len = $1.strlen + strlen ($2);
size_t frag_len = strlen ($2);
size_t req_len = $1.strlen + frag_len;
if ($1.buflen <= req_len) {
size_t newlen = req_len - $1.buflen < REALLOC_STEP ?
$1.buflen + REALLOC_STEP : req_len + 1;
@ -312,7 +313,7 @@ hexa_num_sequence
}
if ($1.buf != NULL) {
strcat ($1.buf, $2);
$1.strlen += strlen ($2);
$1.strlen += frag_len;
}
free ($2);
$$ = $1;

Loading…
Cancel
Save