Skip to content

Commit 976eed8

Browse files
committed
examples: cast away constness for reallocating head arrays
When reallocating commit arrays in `opts_add_commit` and `opts_add_refish`, respectively, we simply pass the const pointer to `xrealloc`. As `xrealloc` expects a non-const pointer, though, this will generate a warning with some compilers. Cast away the constness to silence compilers.
1 parent b6b2d9d commit 976eed8

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

examples/describe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static void opts_add_commit(describe_options *opts, const char *commit)
5454
assert(opts != NULL);
5555

5656
sz = ++opts->commit_count * sizeof(opts->commits[0]);
57-
opts->commits = (const char **)xrealloc(opts->commits, sz);
57+
opts->commits = xrealloc((void *) opts->commits, sz);
5858
opts->commits[opts->commit_count - 1] = commit;
5959
}
6060

examples/merge.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static void opts_add_refish(merge_options *opts, const char *refish)
5757
assert(opts != NULL);
5858

5959
sz = ++opts->heads_count * sizeof(opts->heads[0]);
60-
opts->heads = (const char **)xrealloc(opts->heads, sz);
60+
opts->heads = xrealloc((void *) opts->heads, sz);
6161
opts->heads[opts->heads_count - 1] = refish;
6262
}
6363

0 commit comments

Comments
 (0)