Skip to content

Commit 2744646

Browse files
peffgitster
authored andcommitted
oidmap: rename oidmap_free() to oidmap_clear()
This function does not free the oidmap struct itself; it just drops all items from the map (using hashmap_clear_() internally). It should be called oidmap_clear(), per CodingGuidelines. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7a1d2bd commit 2744646

File tree

7 files changed

+10
-9
lines changed

7 files changed

+10
-9
lines changed

builtin/rev-list.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ int cmd_rev_list(int argc,
924924
free((void *)entry->path);
925925
}
926926

927-
oidmap_free(&missing_objects, true);
927+
oidmap_clear(&missing_objects, true);
928928
}
929929

930930
stop_progress(&progress);

list-objects-filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ static void filter_trees_free(void *filter_data) {
244244
struct filter_trees_depth_data *d = filter_data;
245245
if (!d)
246246
return;
247-
oidmap_free(&d->seen_at_depth, 1);
247+
oidmap_clear(&d->seen_at_depth, 1);
248248
free(d);
249249
}
250250

object-store.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@ void raw_object_store_clear(struct raw_object_store *o)
10171017
{
10181018
FREE_AND_NULL(o->alternate_db);
10191019

1020-
oidmap_free(o->replace_map, 1);
1020+
oidmap_clear(o->replace_map, 1);
10211021
FREE_AND_NULL(o->replace_map);
10221022
pthread_mutex_destroy(&o->replace_mutex);
10231023

oidmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void oidmap_init(struct oidmap *map, size_t initial_size)
2222
hashmap_init(&map->map, oidmap_neq, NULL, initial_size);
2323
}
2424

25-
void oidmap_free(struct oidmap *map, int free_entries)
25+
void oidmap_clear(struct oidmap *map, int free_entries)
2626
{
2727
if (!map)
2828
return;

oidmap.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,13 @@ struct oidmap {
3636
void oidmap_init(struct oidmap *map, size_t initial_size);
3737

3838
/*
39-
* Frees an oidmap structure and allocated memory.
39+
* Clear an oidmap, freeing any allocated memory. The map is empty and
40+
* can be reused without another explicit init.
4041
*
4142
* If `free_entries` is true, each oidmap_entry in the map is freed as well
4243
* using stdlibs free().
4344
*/
44-
void oidmap_free(struct oidmap *map, int free_entries);
45+
void oidmap_clear(struct oidmap *map, int free_entries);
4546

4647
/*
4748
* Returns the oidmap entry for the specified oid, or NULL if not found.

sequencer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6053,8 +6053,8 @@ static int make_script_with_merges(struct pretty_print_context *pp,
60536053
oidset_clear(&interesting);
60546054
oidset_clear(&child_seen);
60556055
oidset_clear(&shown);
6056-
oidmap_free(&commit2todo, 1);
6057-
oidmap_free(&state.commit2label, 1);
6056+
oidmap_clear(&commit2todo, 1);
6057+
oidmap_clear(&state.commit2label, 1);
60586058
hashmap_clear_and_free(&state.labels, struct labels_entry, entry);
60596059
strbuf_release(&state.buf);
60606060

t/unit-tests/u-oidmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void test_oidmap__initialize(void)
3535

3636
void test_oidmap__cleanup(void)
3737
{
38-
oidmap_free(&map, 1);
38+
oidmap_clear(&map, 1);
3939
}
4040

4141
void test_oidmap__replace(void)

0 commit comments

Comments
 (0)