]> git.ipfire.org Git - thirdparty/git.git/commit
fast-export: tighten anonymize_mem() interface to handle only strings
authorJeff King <peff@peff.net>
Tue, 23 Jun 2020 15:24:54 +0000 (11:24 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 24 Jun 2020 02:56:26 +0000 (19:56 -0700)
commit7f4075949686dcd01e364049350ac989c5fc2913
treea579916f869c6ac5915dce84075c7bf297ae19b4
parent750bb32589ea157bfe522a66f814a0124c97c41b
fast-export: tighten anonymize_mem() interface to handle only strings

While the anonymize_mem() interface _can_ store arbitrary byte
sequences, none of the callers uses this feature (as of the previous
commit). We'd like to keep it that way, as we'll be exposing the
string-like nature of the anonymization routines to the user. So let's
tighten up the interface a bit:

  - don't treat "len" as an out-parameter from anonymize_mem(); this
    ensures callers treat the pointer result as a NUL-terminated string

  - likewise, don't treat "len" as an out-parameter from generator
    functions

  - swap out "void *" for "char *" as appropriate to signal that we
    don't handle arbitrary memory

  - rename the function to anonymize_str()

This will also open up some optimization opportunities in a future
patch.

Note that we can't drop the "len" parameter entirely. Some callers do
pass in partial strings (e.g., "foo/bar", len=3) to avoid copying, and
we need to handle those still.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/fast-export.c