path: root/pathspec.h
diff options
authorBrandon Williams <>2017-01-04 18:04:01 (GMT)
committerJunio C Hamano <>2017-01-09 02:04:17 (GMT)
commit8aee769fa12ff0d3a4100c3d0359bc33e49db672 (patch)
tree1cfba92290690678c337d37cbe7c4247ed0e7cae /pathspec.h
parent34305f7753f9f044cb280e6d58658cb31b140693 (diff)
pathspec: copy and free owned memory
The 'original' string entry in a pathspec_item is only duplicated some of the time, instead always make a copy of the original and take ownership of the memory. Since both 'match' and 'original' string entries in a pathspec_item are owned by the pathspec struct, they need to be freed when clearing the pathspec struct (in 'clear_pathspec()') and duplicated when copying the pathspec struct (in 'copy_pathspec()'). Also change the type of 'match' and 'original' to 'char *' in order to more explicitly show the ownership of the memory. Signed-off-by: Brandon Williams <> Reviewed-by: Nguyễn Thái Ngọc Duy <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'pathspec.h')
1 files changed, 2 insertions, 2 deletions
diff --git a/pathspec.h b/pathspec.h
index 70a592e..49fd823 100644
--- a/pathspec.h
+++ b/pathspec.h
@@ -25,8 +25,8 @@ struct pathspec {
unsigned magic;
int max_depth;
struct pathspec_item {
- const char *match;
- const char *original;
+ char *match;
+ char *original;
unsigned magic;
int len, prefix;
int nowildcard_len;