summaryrefslogtreecommitdiff
path: root/src/pkt.c
diff options
context:
space:
mode:
authorRussell Belfer <arrbee@arrbee.com>2011-11-30 11:27:15 -0800
committerRussell Belfer <arrbee@arrbee.com>2011-12-07 23:08:15 -0800
commit97769280ba9938ae27f6e06cbd0d5e8a768a86b9 (patch)
tree4fe43e99acb55f904f6b586bd7c5158610f9512f /src/pkt.c
parenta22b14d32dd8d5f06f121aa154d45bac3b10a305 (diff)
downloadlibgit2-97769280ba9938ae27f6e06cbd0d5e8a768a86b9.tar.gz
Use git_buf for path storage instead of stack-based buffers
This converts virtually all of the places that allocate GIT_PATH_MAX buffers on the stack for manipulating paths to use git_buf objects instead. The patch is pretty careful not to touch the public API for libgit2, so there are a few places that still use GIT_PATH_MAX. This extends and changes some details of the git_buf implementation to add a couple of extra functions and to make error handling easier. This includes serious alterations to all the path.c functions, and several of the fileops.c ones, too. Also, there are a number of new functions that parallel existing ones except that use a git_buf instead of a stack-based buffer (such as git_config_find_global_r that exists alongsize git_config_find_global). This also modifies the win32 version of p_realpath to allocate whatever buffer size is needed to accommodate the realpath instead of hardcoding a GIT_PATH_MAX limit, but that change needs to be tested still.
Diffstat (limited to 'src/pkt.c')
-rw-r--r--src/pkt.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/pkt.c b/src/pkt.c
index 9dfc40255..324265089 100644
--- a/src/pkt.c
+++ b/src/pkt.c
@@ -268,8 +268,7 @@ void git_pkt_free(git_pkt *pkt)
int git_pkt_buffer_flush(git_buf *buf)
{
- git_buf_put(buf, pkt_flush_str, strlen(pkt_flush_str));
- return git_buf_oom(buf) ? GIT_ENOMEM : GIT_SUCCESS;
+ return git_buf_put(buf, pkt_flush_str, strlen(pkt_flush_str));
}
int git_pkt_send_flush(int s)
@@ -291,9 +290,7 @@ static int buffer_want_with_caps(git_remote_head *head, git_transport_caps *caps
git_buf_grow(buf, buf->size + len);
git_oid_fmt(oid, &head->oid);
- git_buf_printf(buf, "%04xwant %s%c%s\n", len, oid, 0, capstr);
-
- return git_buf_oom(buf) ? GIT_ENOMEM : GIT_SUCCESS;
+ return git_buf_printf(buf, "%04xwant %s%c%s\n", len, oid, 0, capstr);
}
static int send_want_with_caps(git_remote_head *head, git_transport_caps *caps, GIT_SOCKET fd)
@@ -401,8 +398,7 @@ int git_pkt_buffer_have(git_oid *oid, git_buf *buf)
memset(oidhex, 0x0, sizeof(oidhex));
git_oid_fmt(oidhex, oid);
- git_buf_printf(buf, "%s%s\n", pkt_have_prefix, oidhex);
- return git_buf_oom(buf) ? GIT_ENOMEM : GIT_SUCCESS;
+ return git_buf_printf(buf, "%s%s\n", pkt_have_prefix, oidhex);
}
int git_pkt_send_have(git_oid *oid, int fd)
@@ -416,8 +412,7 @@ int git_pkt_send_have(git_oid *oid, int fd)
int git_pkt_buffer_done(git_buf *buf)
{
- git_buf_puts(buf, pkt_done_str);
- return git_buf_oom(buf) ? GIT_ENOMEM : GIT_SUCCESS;
+ return git_buf_puts(buf, pkt_done_str);
}
int git_pkt_send_done(int fd)