]> git.ipfire.org Git - thirdparty/git.git/commitdiff
fast-export: drop const when storing anonymized values
authorJeff King <peff@peff.net>
Wed, 22 Mar 2023 17:37:17 +0000 (13:37 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 22 Mar 2023 22:37:08 +0000 (15:37 -0700)
We store anonymized values as pointers to "const char *", since they are
conceptually const to callers who use them. But they are actually
allocated strings whose memory is owned by the struct.

The ownership mismatch hasn't been a big deal since we never free() them
(they are held until the program ends), but let's switch them to "char *"
in preparation for changing that.

Since most code only accesses them via anonymize_str(), it can continue
to narrow them to "const char *" in its return value.

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

index 78493c6d2bf877e6f47b6ad0b80f11b40f36da7b..f422819c82a32d27d0dc73c821c033bb190dffa2 100644 (file)
@@ -110,7 +110,7 @@ static struct decoration idnums;
 static uint32_t last_idnum;
 struct anonymized_entry {
        struct hashmap_entry hash;
-       const char *anon;
+       char *anon;
        const char orig[FLEX_ARRAY];
 };