CLEANUP: chunk: Remove duplicated chunk_Xcat implementation
Delegate chunk_istcat, chunk_cat and chunk_strncat to the most generic chunk_memcat.
This commit is contained in:
parent
9f7ed8a60c
commit
8f1d178cd1
|
@ -107,28 +107,6 @@ static inline int chunk_cpy(struct buffer *chk, const struct buffer *src)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* appends chunk <src> after <chk>. Returns 0 in case of failure. */
|
|
||||||
static inline int chunk_cat(struct buffer *chk, const struct buffer *src)
|
|
||||||
{
|
|
||||||
if (unlikely(chk->data + src->data > chk->size))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
memcpy(chk->area + chk->data, src->area, src->data);
|
|
||||||
chk->data += src->data;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* appends ist <src> after <chk>. Returns 0 in case of failure. */
|
|
||||||
static inline int chunk_istcat(struct buffer *chk, const struct ist src)
|
|
||||||
{
|
|
||||||
if (unlikely(chk->data + src.len > chk->size))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
memcpy(chk->area + chk->data, src.ptr, src.len);
|
|
||||||
chk->data += src.len;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* copies memory area <src> into <chk> for <len> bytes. Returns 0 in
|
/* copies memory area <src> into <chk> for <len> bytes. Returns 0 in
|
||||||
* case of failure. No trailing zero is added.
|
* case of failure. No trailing zero is added.
|
||||||
*/
|
*/
|
||||||
|
@ -158,6 +136,18 @@ static inline int chunk_memcat(struct buffer *chk, const char *src,
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* appends ist <src> after <chk>. Returns 0 in case of failure. */
|
||||||
|
static inline int chunk_istcat(struct buffer *chk, const struct ist src)
|
||||||
|
{
|
||||||
|
return chunk_memcat(chk, istptr(src), istlen(src));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* appends chunk <src> after <chk>. Returns 0 in case of failure. */
|
||||||
|
static inline int chunk_cat(struct buffer *chk, const struct buffer *src)
|
||||||
|
{
|
||||||
|
return chunk_memcat(chk, src->area, src->data);
|
||||||
|
}
|
||||||
|
|
||||||
/* copies str into <chk> followed by a trailing zero. Returns 0 in
|
/* copies str into <chk> followed by a trailing zero. Returns 0 in
|
||||||
* case of failure.
|
* case of failure.
|
||||||
*/
|
*/
|
||||||
|
@ -218,12 +208,7 @@ static inline int chunk_strcat(struct buffer *chk, const char *str)
|
||||||
*/
|
*/
|
||||||
static inline int chunk_strncat(struct buffer *chk, const char *str, int nb)
|
static inline int chunk_strncat(struct buffer *chk, const char *str, int nb)
|
||||||
{
|
{
|
||||||
if (unlikely(chk->data + nb >= chk->size))
|
return chunk_memcat(chk, str, nb);
|
||||||
return 0;
|
|
||||||
|
|
||||||
memcpy(chk->area + chk->data, str, nb);
|
|
||||||
chk->data += nb;
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Adds a trailing zero to the current chunk and returns the pointer to the
|
/* Adds a trailing zero to the current chunk and returns the pointer to the
|
||||||
|
|
Loading…
Reference in New Issue