]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: log: merge lf_encode_string() and lf_encode_chunk() logic
authorAurelien DARRAGON <adarragon@haproxy.com>
Fri, 26 Apr 2024 11:53:15 +0000 (13:53 +0200)
committerAurelien DARRAGON <adarragon@haproxy.com>
Fri, 26 Apr 2024 16:39:31 +0000 (18:39 +0200)
commitf7cb384f1a34bda53d7d62da26f5ba864da723de
treed0e634acbdf3649ea932cd99a9ce5a426bda5c85
parenta1583ec7c789389414b6baf8e29563810a6c9561
MINOR: log: merge lf_encode_string() and lf_encode_chunk() logic

lf_encode_string() and lf_encode_chunk() function are pretty similar. The
only difference is the stopping behavior, encode_chunk stops at a given
position while encode_string stops when encountering '\0'. Moreover,
both functions leverage tools.c encode helpers, but because of the
LOG_OPT_ESC option, they reimplement those helpers with added logic.

Instead of having to deal with code duplication which makes both functions
harder to maintain, let's define a _lf_encode_bytes() helper function
which satisfies lf_encode_string() and lf_encode_chunk() needs while
keeping the function as simple as possible.

_lf_encode_bytes() itself is made of multiple static inline helper
functions, in the attempt to keep checks outside of core loop for
better performance.
src/log.c