From 97769280ba9938ae27f6e06cbd0d5e8a768a86b9 Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Wed, 30 Nov 2011 11:27:15 -0800 Subject: 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. --- src/posix.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/posix.c') diff --git a/src/posix.c b/src/posix.c index 8c19588ee..916aad726 100644 --- a/src/posix.c +++ b/src/posix.c @@ -35,7 +35,8 @@ int p_getcwd(char *buffer_out, size_t size) git_path_mkposix(buffer_out); - git_path_join(buffer_out, buffer_out, ""); //Ensure the path ends with a trailing slash + git_path_string_to_dir(buffer_out, size); //Ensure the path ends with a trailing slash + return GIT_SUCCESS; } -- cgit v1.2.1