mirror of
https://github.com/yarrick/iodine.git
synced 2025-05-15 15:08:16 +00:00
Optimize strlen calls in putname
Working version of https://github.com/yarrick/iodine/pull/111
This commit is contained in:
parent
50caf2c45f
commit
f12d2a5554
11
src/read.c
11
src/read.c
@ -168,15 +168,16 @@ putname(char **buf, size_t buflen, const char *host)
|
|||||||
|
|
||||||
word = strtok(h, ".");
|
word = strtok(h, ".");
|
||||||
while(word) {
|
while(word) {
|
||||||
if (strlen(word) > 63 || strlen(word) > left) {
|
size_t word_len = strlen(word);
|
||||||
|
if (word_len > 63 || word_len > left) {
|
||||||
free(h);
|
free(h);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
left -= (strlen(word) + 1);
|
left -= (word_len + 1);
|
||||||
*p++ = (char)strlen(word);
|
*p++ = (char)word_len;
|
||||||
memcpy(p, word, strlen(word));
|
memcpy(p, word, word_len);
|
||||||
p += strlen(word);
|
p += word_len;
|
||||||
|
|
||||||
word = strtok(NULL, ".");
|
word = strtok(NULL, ".");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user