@@ -47,10 +47,9 @@ char *mksnpath(char *buf, size_t n, const char *fmt, ...)
47
47
return cleanup_path (buf );
48
48
}
49
49
50
- char * git_snpath (char * buf , size_t n , const char * fmt , ... )
50
+ static char * git_vsnpath (char * buf , size_t n , const char * fmt , va_list args )
51
51
{
52
52
const char * git_dir = get_git_dir ();
53
- va_list args ;
54
53
size_t len ;
55
54
56
55
len = strlen (git_dir );
@@ -59,9 +58,7 @@ char *git_snpath(char *buf, size_t n, const char *fmt, ...)
59
58
memcpy (buf , git_dir , len );
60
59
if (len && !is_dir_sep (git_dir [len - 1 ]))
61
60
buf [len ++ ] = '/' ;
62
- va_start (args , fmt );
63
61
len += vsnprintf (buf + len , n - len , fmt , args );
64
- va_end (args );
65
62
if (len >= n )
66
63
goto bad ;
67
64
return cleanup_path (buf );
@@ -70,6 +67,25 @@ char *git_snpath(char *buf, size_t n, const char *fmt, ...)
70
67
return buf ;
71
68
}
72
69
70
+ char * git_snpath (char * buf , size_t n , const char * fmt , ...)
71
+ {
72
+ va_list args ;
73
+ va_start (args , fmt );
74
+ (void )git_vsnpath (buf , n , fmt , args );
75
+ va_end (args );
76
+ return buf ;
77
+ }
78
+
79
+ char * git_pathdup (const char * fmt , ...)
80
+ {
81
+ char path [PATH_MAX ];
82
+ va_list args ;
83
+ va_start (args , fmt );
84
+ (void )git_vsnpath (path , sizeof (path ), fmt , args );
85
+ va_end (args );
86
+ return xstrdup (path );
87
+ }
88
+
73
89
char * mkpath (const char * fmt , ...)
74
90
{
75
91
va_list args ;
0 commit comments