All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
	Jonathan Niedier <jrnieder@gmail.com>,
	Matthieu.Moy@grenoble-inp.fr
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 2/3] Make prefix_path() return char* without const
Date: Thu, 11 Nov 2010 21:08:03 +0700	[thread overview]
Message-ID: <1289484484-8632-3-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <1289484484-8632-1-git-send-email-pclouds@gmail.com>

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>
---
 cache.h |    2 +-
 setup.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/cache.h b/cache.h
index 222d9cf..bd181c6 100644
--- a/cache.h
+++ b/cache.h
@@ -428,7 +428,7 @@ extern const char **get_pathspec(const char *prefix, const char **pathspec);
 extern void setup_work_tree(void);
 extern const char *setup_git_directory_gently(int *);
 extern const char *setup_git_directory(void);
-extern const char *prefix_path(const char *prefix, int len, const char *path);
+extern char *prefix_path(const char *prefix, int len, const char *path);
 extern const char *prefix_filename(const char *prefix, int len, const char *path);
 extern int check_filename(const char *prefix, const char *name);
 extern void verify_filename(const char *prefix, const char *name);
diff --git a/setup.c b/setup.c
index 833db12..f930dc0 100644
--- a/setup.c
+++ b/setup.c
@@ -4,7 +4,7 @@
 static int inside_git_dir = -1;
 static int inside_work_tree = -1;
 
-const char *prefix_path(const char *prefix, int len, const char *path)
+char *prefix_path(const char *prefix, int len, const char *path)
 {
 	const char *orig = path;
 	char *sanitized = xmalloc(len + strlen(path) + 1);
-- 
1.7.3.2.210.g045198

  parent reply	other threads:[~2010-11-11 14:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-11 14:08 [PATCH 0/3] Support relative path in <blah>:path syntax Nguyễn Thái Ngọc Duy
2010-11-11 14:08 ` [PATCH 1/3] setup: save prefix (original cwd relative to toplevel) in startup_info Nguyễn Thái Ngọc Duy
2010-11-11 14:08 ` Nguyễn Thái Ngọc Duy [this message]
2010-11-11 14:08 ` [PATCH 3/3] get_sha1: support relative path ":path" syntax Nguyễn Thái Ngọc Duy
2010-11-14 20:22   ` Thiago Farina
2010-11-15  3:56     ` [PATCH] " Nguyễn Thái Ngọc Duy
2010-11-15 14:56       ` Sverre Rabbelier
2010-11-15 17:29         ` Junio C Hamano
2010-11-15 18:59           ` Junio C Hamano
2010-11-28  3:37           ` Nguyễn Thái Ngọc Duy
2010-11-17 17:54 ` [PATCH 0/3] Support relative path in <blah>:path syntax Junio C Hamano
2010-11-18  1:47   ` Nguyen Thai Ngoc Duy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1289484484-8632-3-git-send-email-pclouds@gmail.com \
    --to=pclouds@gmail.com \
    --cc=Matthieu.Moy@grenoble-inp.fr \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jrnieder@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.