Make prefix_path() return char* without const
prefix_path() allocates new buffer. There's no reason for it to keep the buffer for itself and waste memory. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Nov 11, 2010 at 21:08 UTC
edc54fb5d4ce6774fc2ac76779bd57dc2d6ab189
2 files changed
+2
-2
cache.h
+1
-1
@@ -428,7 +428,7 @@ extern const char **get_pathspec(const char *prefix, const char **pathspec);
428
extern void setup_work_tree(void);
429
extern const char *setup_git_directory_gently(int *);
430
extern const char *setup_git_directory(void);
431
-extern const char *prefix_path(const char *prefix, int len, const char *path);
431
+extern char *prefix_path(const char *prefix, int len, const char *path);
432
extern const char *prefix_filename(const char *prefix, int len, const char *path);
433
extern int check_filename(const char *prefix, const char *name);
434
extern void verify_filename(const char *prefix, const char *name);
setup.c
+1
-1
@@ -4,7 +4,7 @@
4
static int inside_git_dir = -1;
5
static int inside_work_tree = -1;
6
7
-const char *prefix_path(const char *prefix, int len, const char *path)
7
+char *prefix_path(const char *prefix, int len, const char *path)
8
{
9
const char *orig = path;
10
char *sanitized = xmalloc(len + strlen(path) + 1);