155
* is farmed out to the generate function.
156
*/
157
static const char *anonymize_str(struct hashmap *map,
158
- char *(*generate)(const char *, size_t),
159
- const char *orig, size_t len)
158
+ char *(*generate)(void *),
159
+ const char *orig, size_t len,
160
+ void *data)
161
{
162
struct anonymized_entry_key key;
163
struct anonymized_entry *ret;
173
if (!ret) {
174
FLEX_ALLOC_MEM(ret, orig, orig, len);
175
hashmap_entry_init(&ret->hash, key.hash.hash);
175
- ret->anon = generate(orig, len);
176
+ ret->anon = generate(data);
177
hashmap_put(map, &ret->hash);
178
}
179
188
*/
189
static void anonymize_path(struct strbuf *out, const char *path,
190
struct hashmap *map,
190
- char *(*generate)(const char *, size_t))
191
+ char *(*generate)(void *))
192
{
193
while (*path) {
194
const char *end_of_component = strchrnul(path, '/');
195
size_t len = end_of_component - path;
195
- const char *c = anonymize_str(map, generate, path, len);
196
+ const char *c = anonymize_str(map, generate, path, len, NULL);
197
strbuf_addstr(out, c);
198
path = end_of_component;
199
if (*path)
368
printf("%s", path);
369
}
370
370
-static char *anonymize_path_component(const char *path, size_t len)
371
+static char *anonymize_path_component(void *data)
372
{
373
static int counter;
374
struct strbuf out = STRBUF_INIT;
390
}
391
}
392
392
-static char *generate_fake_oid(const char *old, size_t len)
393
+static char *generate_fake_oid(void *data)
394
{
395
static uint32_t counter = 1; /* avoid null oid */
396
const unsigned hashsz = the_hash_algo->rawsz;
406
{
407
static struct hashmap objs;
408
size_t len = strlen(oid_hex);
408
- return anonymize_str(&objs, generate_fake_oid, oid_hex, len);
409
+ return anonymize_str(&objs, generate_fake_oid, oid_hex, len, NULL);
410
}
411
412
static void show_filemodify(struct diff_queue_struct *q,
503
return bol;
504
}
505
505
-static char *anonymize_ref_component(const char *old, size_t len)
506
+static char *anonymize_ref_component(void *data)
507
{
508
static int counter;
509
struct strbuf out = STRBUF_INIT;
556
return xstrfmt("subject %d\n\nbody\n", counter++);
557
}
558
558
-static char *anonymize_ident(const char *old, size_t len)
559
+static char *anonymize_ident(void *data)
560
{
561
static int counter;
562
struct strbuf out = STRBUF_INIT;
599
600
len = split.mail_end - split.name_begin;
601
ident = anonymize_str(&idents, anonymize_ident,
601
- split.name_begin, len);
602
+ split.name_begin, len, NULL);
603
strbuf_addstr(out, ident);
604
strbuf_addch(out, ' ');
605
strbuf_add(out, split.date_begin, split.tz_end - split.date_begin);
740
show_progress();
741
}
742
742
-static char *anonymize_tag(const char *old, size_t len)
743
+static char *anonymize_tag(void *data)
744
{
745
static int counter;
746
struct strbuf out = STRBUF_INIT;
816
if (message) {
817
static struct hashmap tags;
818
message = anonymize_str(&tags, anonymize_tag,
818
- message, message_size);
819
+ message, message_size, NULL);
820
}
821
}
822