pathspec: match and original in pathspec_item are const
No existing code modifies these two strings in pathspec elements after they are created via these two pointers. Declare them as "const char *" to stress on this fact and cast away constness from the code that frees these two strings. Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
1 parent
a89346e34a
commit
88d06b1c91
2 files changed
+4
-4
No files matched your search
+2
-2
@@ -749,8 +749,8 @@ void clear_pathspec(struct pathspec *pathspec)
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < pathspec->nr; i++) {
|
||||
free(pathspec->items[i].match);
|
||||
free(pathspec->items[i].original);
|
||||
free((void *)pathspec->items[i].match);
|
||||
free((void *)pathspec->items[i].original);
|
||||
|
||||
for (j = 0; j < pathspec->items[i].attr_match_nr; j++)
|
||||
free(pathspec->items[i].attr_match[j].value);
|
||||
|
||||
+2
-2
@@ -35,8 +35,8 @@ struct pathspec {
|
||||
unsigned magic;
|
||||
int max_depth;
|
||||
struct pathspec_item {
|
||||
char *match;
|
||||
char *original;
|
||||
const char *match;
|
||||
const char *original;
|
||||
unsigned magic;
|
||||
int len, prefix;
|
||||
int nowildcard_len;
|
||||
|
||||
Reference in new issue
Block a user