From: Faiz Kothari <faiz.off93@gmail.com>
To: git@vger.kernel.org
Cc: Faiz Kothari <faiz.off93@gmail.com>
Subject: [PATCH] GSoC2014 Microproject rewrite finish_bulk_checkin()
Date: Fri, 28 Feb 2014 00:32:20 +0530 [thread overview]
Message-ID: <1393527740-16765-1-git-send-email-faiz.off93@gmail.com> (raw)
Signed-off-by: Faiz Kothari <faiz.off93@gmail.com>
---
bulk-checkin.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/bulk-checkin.c b/bulk-checkin.c
index 118c625..feeff9f 100644
--- a/bulk-checkin.c
+++ b/bulk-checkin.c
@@ -23,7 +23,7 @@ static struct bulk_checkin_state {
static void finish_bulk_checkin(struct bulk_checkin_state *state)
{
unsigned char sha1[20];
- char packname[PATH_MAX];
+ struct strbuf packname;
int i;
if (!state->f)
@@ -42,9 +42,11 @@ static void finish_bulk_checkin(struct bulk_checkin_state *state)
state->offset);
close(fd);
}
-
- sprintf(packname, "%s/pack/pack-", get_object_directory());
- finish_tmp_packfile(packname, state->pack_tmp_name,
+
+ packname.len = packname.alloc = 64 + strlen(get_object_directory());
+ packname.buf = (char *)malloc(packname.len * sizeof(char));
+ sprintf(packname.buf, "%s/pack/pack-", get_object_directory());
+ finish_tmp_packfile(packname.buf, state->pack_tmp_name,
state->written, state->nr_written,
&state->pack_idx_opts, sha1);
for (i = 0; i < state->nr_written; i++)
@@ -53,7 +55,7 @@ static void finish_bulk_checkin(struct bulk_checkin_state *state)
clear_exit:
free(state->written);
memset(state, 0, sizeof(*state));
-
+ free(packname.buf);
/* Make objects we just wrote available to ourselves */
reprepare_packed_git();
}
--
1.7.9.5
> Rewrite bulk-checkin.c:finish_bulk_checkin() to use a strbuf for handling packname, and explain why this is useful.
> Also check if the first argument of pack-write.c:finish_tmp_packfile() can be made const.
Adding 64 to strlen(get_object_directory()) to accomodate sha1_to_hex(sha1) and itself.
Using the APIs for strbuf is giving me test failures(12/15) during t1050-large.sh
So, I used the malloc() and free() instead.
Instead of having packname on stack and cause stackoverflow because of MAX_PATH ~ 4KB, have it on heap.
Can have first parameter to pack-write.c:finish_tmp_packfile() as const because packname is not required to be modified.
I apologise for my two earlier patches not being in proper format. I have finally got it working properly. Will make sure,
it does not happen again.
next reply other threads:[~2014-02-27 19:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-27 19:02 Faiz Kothari [this message]
2014-02-27 22:17 ` [PATCH] GSoC2014 Microproject rewrite finish_bulk_checkin() Michael Haggerty
2014-02-27 22:35 ` Faiz Kothari
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=1393527740-16765-1-git-send-email-faiz.off93@gmail.com \
--to=faiz.off93@gmail.com \
--cc=git@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).