mirror of
https://github.com/libgit2/libgit2.git
synced 2026-06-22 06:26:26 +00:00
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.
This commit is contained in:
@@ -54,7 +54,7 @@ static void opts_add_commit(describe_options *opts, const char *commit)
|
||||
assert(opts != NULL);
|
||||
|
||||
sz = ++opts->commit_count * sizeof(opts->commits[0]);
|
||||
opts->commits = (const char **)xrealloc(opts->commits, sz);
|
||||
opts->commits = xrealloc((void *) opts->commits, sz);
|
||||
opts->commits[opts->commit_count - 1] = commit;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ static void opts_add_refish(merge_options *opts, const char *refish)
|
||||
assert(opts != NULL);
|
||||
|
||||
sz = ++opts->heads_count * sizeof(opts->heads[0]);
|
||||
opts->heads = (const char **)xrealloc(opts->heads, sz);
|
||||
opts->heads = xrealloc((void *) opts->heads, sz);
|
||||
opts->heads[opts->heads_count - 1] = refish;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user