udhcp: trivial shrink
function old new delta dname_dec 337 332 -5 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
@@ -42,7 +42,7 @@ char* FAST_FUNC dname_dec(const uint8_t *cstr, int clen, const char *pre)
|
|||||||
*/
|
*/
|
||||||
while (1) {
|
while (1) {
|
||||||
/* note: "return NULL" below are leak-safe since
|
/* note: "return NULL" below are leak-safe since
|
||||||
* dst isn't yet allocated */
|
* dst isn't allocated yet */
|
||||||
const uint8_t *c;
|
const uint8_t *c;
|
||||||
unsigned crtpos, retpos, depth, len;
|
unsigned crtpos, retpos, depth, len;
|
||||||
|
|
||||||
@@ -95,9 +95,8 @@ char* FAST_FUNC dname_dec(const uint8_t *cstr, int clen, const char *pre)
|
|||||||
if (!dst) { /* first pass? */
|
if (!dst) { /* first pass? */
|
||||||
/* allocate dst buffer and copy pre */
|
/* allocate dst buffer and copy pre */
|
||||||
unsigned plen = strlen(pre);
|
unsigned plen = strlen(pre);
|
||||||
ret = dst = xmalloc(plen + len);
|
ret = xmalloc(plen + len);
|
||||||
memcpy(dst, pre, plen);
|
dst = stpcpy(ret, pre);
|
||||||
dst += plen;
|
|
||||||
} else {
|
} else {
|
||||||
dst[len - 1] = '\0';
|
dst[len - 1] = '\0';
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user