commit-graph: use size_t for array allocation and indexing
authorJeff King <redacted>
Mon, 7 Dec 2020 19:11:08 +0000 (14:11 -0500)
committerJunio C Hamano <redacted>
Mon, 7 Dec 2020 20:32:04 +0000 (12:32 -0800)
Our packed_commit_list is an array of pointers to commit structs. We use
"int" for the allocation, which is 32-bit even on 64-bit platforms. This
isn't likely to overflow in practice (we're writing commit graphs, so
you'd need to actually have billions of unique commits in the
repository). But it's good practice to use size_t for allocations.

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
commit-graph.c

index 4a718fd6e67422eb41666c144cd1311020e96479..06f8dc1d8966f1ec59f58460a41df67b63180b24 100644 (file)
@@ -932,8 +932,8 @@ struct tree *get_commit_tree_in_graph(struct repository *r, const struct commit
 
 struct packed_commit_list {
        struct commit **list;
-       int nr;
-       int alloc;
+       size_t nr;
+       size_t alloc;
 };
 
 struct write_commit_graph_context {
git clone https://git.99rst.org/PROJECT