@@ -145,31 +145,30 @@ static int anonymized_entry_cmp(const void *unused_cmp_data,
145
145
* the same anonymized string with another. The actual generation
146
146
* is farmed out to the generate function.
147
147
*/
148
- static const void * anonymize_mem (struct hashmap * map ,
149
- void * (* generate )(const void * , size_t * ),
150
- const void * orig , size_t * len )
148
+ static const char * anonymize_str (struct hashmap * map ,
149
+ char * (* generate )(const char * , size_t ),
150
+ const char * orig , size_t len )
151
151
{
152
152
struct anonymized_entry key , * ret ;
153
153
154
154
if (!map -> cmpfn )
155
155
hashmap_init (map , anonymized_entry_cmp , NULL , 0 );
156
156
157
- hashmap_entry_init (& key .hash , memhash (orig , * len ));
157
+ hashmap_entry_init (& key .hash , memhash (orig , len ));
158
158
key .orig = orig ;
159
- key .orig_len = * len ;
159
+ key .orig_len = len ;
160
160
ret = hashmap_get_entry (map , & key , hash , NULL );
161
161
162
162
if (!ret ) {
163
163
ret = xmalloc (sizeof (* ret ));
164
164
hashmap_entry_init (& ret -> hash , key .hash .hash );
165
- ret -> orig = xmemdupz (orig , * len );
166
- ret -> orig_len = * len ;
165
+ ret -> orig = xmemdupz (orig , len );
166
+ ret -> orig_len = len ;
167
167
ret -> anon = generate (orig , len );
168
- ret -> anon_len = * len ;
168
+ ret -> anon_len = strlen ( ret -> anon ) ;
169
169
hashmap_put (map , & ret -> hash );
170
170
}
171
171
172
- * len = ret -> anon_len ;
173
172
return ret -> anon ;
174
173
}
175
174
@@ -181,13 +180,13 @@ static const void *anonymize_mem(struct hashmap *map,
181
180
*/
182
181
static void anonymize_path (struct strbuf * out , const char * path ,
183
182
struct hashmap * map ,
184
- void * (* generate )(const void * , size_t * ))
183
+ char * (* generate )(const char * , size_t ))
185
184
{
186
185
while (* path ) {
187
186
const char * end_of_component = strchrnul (path , '/' );
188
187
size_t len = end_of_component - path ;
189
- const char * c = anonymize_mem (map , generate , path , & len );
190
- strbuf_add (out , c , len );
188
+ const char * c = anonymize_str (map , generate , path , len );
189
+ strbuf_addstr (out , c );
191
190
path = end_of_component ;
192
191
if (* path )
193
192
strbuf_addch (out , * path ++ );
@@ -361,12 +360,12 @@ static void print_path_1(const char *path)
361
360
printf ("%s" , path );
362
361
}
363
362
364
- static void * anonymize_path_component (const void * path , size_t * len )
363
+ static char * anonymize_path_component (const char * path , size_t len )
365
364
{
366
365
static int counter ;
367
366
struct strbuf out = STRBUF_INIT ;
368
367
strbuf_addf (& out , "path%d" , counter ++ );
369
- return strbuf_detach (& out , len );
368
+ return strbuf_detach (& out , NULL );
370
369
}
371
370
372
371
static void print_path (const char * path )
@@ -383,7 +382,7 @@ static void print_path(const char *path)
383
382
}
384
383
}
385
384
386
- static void * generate_fake_oid (const void * old , size_t * len )
385
+ static char * generate_fake_oid (const char * old , size_t len )
387
386
{
388
387
static uint32_t counter = 1 ; /* avoid null oid */
389
388
const unsigned hashsz = the_hash_algo -> rawsz ;
@@ -399,7 +398,7 @@ static const char *anonymize_oid(const char *oid_hex)
399
398
{
400
399
static struct hashmap objs ;
401
400
size_t len = strlen (oid_hex );
402
- return anonymize_mem (& objs , generate_fake_oid , oid_hex , & len );
401
+ return anonymize_str (& objs , generate_fake_oid , oid_hex , len );
403
402
}
404
403
405
404
static void show_filemodify (struct diff_queue_struct * q ,
@@ -496,12 +495,12 @@ static const char *find_encoding(const char *begin, const char *end)
496
495
return bol ;
497
496
}
498
497
499
- static void * anonymize_ref_component (const void * old , size_t * len )
498
+ static char * anonymize_ref_component (const char * old , size_t len )
500
499
{
501
500
static int counter ;
502
501
struct strbuf out = STRBUF_INIT ;
503
502
strbuf_addf (& out , "ref%d" , counter ++ );
504
- return strbuf_detach (& out , len );
503
+ return strbuf_detach (& out , NULL );
505
504
}
506
505
507
506
static const char * anonymize_refname (const char * refname )
@@ -550,13 +549,13 @@ static char *anonymize_commit_message(const char *old)
550
549
}
551
550
552
551
static struct hashmap idents ;
553
- static void * anonymize_ident (const void * old , size_t * len )
552
+ static char * anonymize_ident (const char * old , size_t len )
554
553
{
555
554
static int counter ;
556
555
struct strbuf out = STRBUF_INIT ;
557
556
strbuf_addf (
& out ,
"User %d <user%[email protected] >" ,
counter ,
counter );
558
557
counter ++ ;
559
- return strbuf_detach (& out , len );
558
+ return strbuf_detach (& out , NULL );
560
559
}
561
560
562
561
/*
@@ -591,9 +590,9 @@ static void anonymize_ident_line(const char **beg, const char **end)
591
590
size_t len ;
592
591
593
592
len = split .mail_end - split .name_begin ;
594
- ident = anonymize_mem (& idents , anonymize_ident ,
595
- split .name_begin , & len );
596
- strbuf_add (out , ident , len );
593
+ ident = anonymize_str (& idents , anonymize_ident ,
594
+ split .name_begin , len );
595
+ strbuf_addstr (out , ident );
597
596
strbuf_addch (out , ' ' );
598
597
strbuf_add (out , split .date_begin , split .tz_end - split .date_begin );
599
598
} else {
@@ -733,12 +732,12 @@ static void handle_commit(struct commit *commit, struct rev_info *rev,
733
732
show_progress ();
734
733
}
735
734
736
- static void * anonymize_tag (const void * old , size_t * len )
735
+ static char * anonymize_tag (const char * old , size_t len )
737
736
{
738
737
static int counter ;
739
738
struct strbuf out = STRBUF_INIT ;
740
739
strbuf_addf (& out , "tag message %d" , counter ++ );
741
- return strbuf_detach (& out , len );
740
+ return strbuf_detach (& out , NULL );
742
741
}
743
742
744
743
static void handle_tail (struct object_array * commits , struct rev_info * revs ,
@@ -808,8 +807,8 @@ static void handle_tag(const char *name, struct tag *tag)
808
807
name = anonymize_refname (name );
809
808
if (message ) {
810
809
static struct hashmap tags ;
811
- message = anonymize_mem (& tags , anonymize_tag ,
812
- message , & message_size );
810
+ message = anonymize_str (& tags , anonymize_tag ,
811
+ message , message_size );
813
812
}
814
813
}
815
814
0 commit comments