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, ".");
|
||||
while(word) {
|
||||
if (strlen(word) > 63 || strlen(word) > left) {
|
||||
size_t word_len = strlen(word);
|
||||
if (word_len > 63 || word_len > left) {
|
||||
free(h);
|
||||
return -1;
|
||||
}
|
||||
|
||||
left -= (strlen(word) + 1);
|
||||
*p++ = (char)strlen(word);
|
||||
memcpy(p, word, strlen(word));
|
||||
p += strlen(word);
|
||||
left -= (word_len + 1);
|
||||
*p++ = (char)word_len;
|
||||
memcpy(p, word, word_len);
|
||||
p += word_len;
|
||||
|
||||
word = strtok(NULL, ".");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user