* is farmed out to the generate function.
*/
static const char *anonymize_str(struct hashmap *map,
- char *(*generate)(const char *, size_t),
- const char *orig, size_t len)
+ char *(*generate)(void *),
+ const char *orig, size_t len,
+ void *data)
{
struct anonymized_entry_key key;
struct anonymized_entry *ret;
if (!ret) {
FLEX_ALLOC_MEM(ret, orig, orig, len);
hashmap_entry_init(&ret->hash, key.hash.hash);
- ret->anon = generate(orig, len);
+ ret->anon = generate(data);
hashmap_put(map, &ret->hash);
}
*/
static void anonymize_path(struct strbuf *out, const char *path,
struct hashmap *map,
- char *(*generate)(const char *, size_t))
+ char *(*generate)(void *))
{
while (*path) {
const char *end_of_component = strchrnul(path, '/');
size_t len = end_of_component - path;
- const char *c = anonymize_str(map, generate, path, len);
+ const char *c = anonymize_str(map, generate, path, len, NULL);
strbuf_addstr(out, c);
path = end_of_component;
if (*path)
printf("%s", path);
}
-static char *anonymize_path_component(const char *path, size_t len)
+static char *anonymize_path_component(void *data)
{
static int counter;
struct strbuf out = STRBUF_INIT;
}
}
-static char *generate_fake_oid(const char *old, size_t len)
+static char *generate_fake_oid(void *data)
{
static uint32_t counter = 1; /* avoid null oid */
const unsigned hashsz = the_hash_algo->rawsz;
{
static struct hashmap objs;
size_t len = strlen(oid_hex);
- return anonymize_str(&objs, generate_fake_oid, oid_hex, len);
+ return anonymize_str(&objs, generate_fake_oid, oid_hex, len, NULL);
}
static void show_filemodify(struct diff_queue_struct *q,
return bol;
}
-static char *anonymize_ref_component(const char *old, size_t len)
+static char *anonymize_ref_component(void *data)
{
static int counter;
struct strbuf out = STRBUF_INIT;
return xstrfmt("subject %d\n\nbody\n", counter++);
}
-static char *anonymize_ident(const char *old, size_t len)
+static char *anonymize_ident(void *data)
{
static int counter;
struct strbuf out = STRBUF_INIT;
len = split.mail_end - split.name_begin;
ident = anonymize_str(&idents, anonymize_ident,
- split.name_begin, len);
+ split.name_begin, len, NULL);
strbuf_addstr(out, ident);
strbuf_addch(out, ' ');
strbuf_add(out, split.date_begin, split.tz_end - split.date_begin);
show_progress();
}
-static char *anonymize_tag(const char *old, size_t len)
+static char *anonymize_tag(void *data)
{
static int counter;
struct strbuf out = STRBUF_INIT;
if (message) {
static struct hashmap tags;
message = anonymize_str(&tags, anonymize_tag,
- message, message_size);
+ message, message_size, NULL);
}
}