diff options
| author | Jeff King <peff@peff.net> | 2016-06-23 13:33:57 -0400 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2016-06-23 11:32:51 -0700 |
| commit | ae989a61dad98debe9899823ca987305f8e8020d (patch) | |
| tree | 72cf418dce266b14852818aacc09953f6ecef187 /commit.c | |
| parent | doc: refactor description of color format (diff) | |
| download | git-ae989a61dad98debe9899823ca987305f8e8020d.tar.gz git-ae989a61dad98debe9899823ca987305f8e8020d.zip | |
add skip_prefix_mem helper
The skip_prefix function has been very useful for
simplifying pointer arithmetic and avoiding repeated magic
numbers, but we have no equivalent for length-limited
buffers. So we're stuck with:
if (3 <= len && skip_prefix(buf, "foo", &buf))
len -= 3;
That's not that complicated, but it needs to use magic
numbers for the length of the prefix (or else write out
strlen("foo"), repeating the string). By using a helper, we
can get the string length behind the scenes (and often at
compile time for string literals).
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit.c')
0 files changed, 0 insertions, 0 deletions
