@@ -321,13 +321,12 @@ static char *find_name(const char *line, char *def, int p_value, int terminate)
321321 const char * start = line ;
322322
323323 if (* line == '"' ) {
324- struct strbuf name ;
324+ struct strbuf name = STRBUF_INIT ;
325325
326326 /*
327327 * Proposed "new-style" GNU patch/diff format; see
328328 * http://marc.theaimsgroup.com/?l=git&m=112927316408690&w=2
329329 */
330- strbuf_init (& name , 0 );
331330 if (!unquote_c_style (& name , line , NULL )) {
332331 char * cp ;
333332
@@ -675,11 +674,8 @@ static char *git_header_name(char *line, int llen)
675674
676675 if (* line == '"' ) {
677676 const char * cp ;
678- struct strbuf first ;
679- struct strbuf sp ;
680-
681- strbuf_init (& first , 0 );
682- strbuf_init (& sp , 0 );
677+ struct strbuf first = STRBUF_INIT ;
678+ struct strbuf sp = STRBUF_INIT ;
683679
684680 if (unquote_c_style (& first , line , & second ))
685681 goto free_and_fail1 ;
@@ -741,10 +737,9 @@ static char *git_header_name(char *line, int llen)
741737 */
742738 for (second = name ; second < line + llen ; second ++ ) {
743739 if (* second == '"' ) {
744- struct strbuf sp ;
740+ struct strbuf sp = STRBUF_INIT ;
745741 const char * np ;
746742
747- strbuf_init (& sp , 0 );
748743 if (unquote_c_style (& sp , second , NULL ))
749744 goto free_and_fail2 ;
750745
@@ -1508,11 +1503,10 @@ static const char minuses[]=
15081503
15091504static void show_stats (struct patch * patch )
15101505{
1511- struct strbuf qname ;
1506+ struct strbuf qname = STRBUF_INIT ;
15121507 char * cp = patch -> new_name ? patch -> new_name : patch -> old_name ;
15131508 int max , add , del ;
15141509
1515- strbuf_init (& qname , 0 );
15161510 quote_c_style (cp , & qname , NULL , 0 );
15171511
15181512 /*
@@ -2292,14 +2286,12 @@ static void add_to_fn_table(struct patch *patch)
22922286
22932287static int apply_data (struct patch * patch , struct stat * st , struct cache_entry * ce )
22942288{
2295- struct strbuf buf ;
2289+ struct strbuf buf = STRBUF_INIT ;
22962290 struct image image ;
22972291 size_t len ;
22982292 char * img ;
22992293 struct patch * tpatch ;
23002294
2301- strbuf_init (& buf , 0 );
2302-
23032295 if (!(patch -> is_copy || patch -> is_rename ) &&
23042296 ((tpatch = in_fn_table (patch -> old_name )) != NULL )) {
23052297 if (tpatch == (struct patch * ) -1 ) {
@@ -2779,7 +2771,7 @@ static void add_index_file(const char *path, unsigned mode, void *buf, unsigned
27792771static int try_create_file (const char * path , unsigned int mode , const char * buf , unsigned long size )
27802772{
27812773 int fd ;
2782- struct strbuf nbuf ;
2774+ struct strbuf nbuf = STRBUF_INIT ;
27832775
27842776 if (S_ISGITLINK (mode )) {
27852777 struct stat st ;
@@ -2798,7 +2790,6 @@ static int try_create_file(const char *path, unsigned int mode, const char *buf,
27982790 if (fd < 0 )
27992791 return -1 ;
28002792
2801- strbuf_init (& nbuf , 0 );
28022793 if (convert_to_working_tree (path , buf , size , & nbuf )) {
28032794 size = nbuf .len ;
28042795 buf = nbuf .buf ;
@@ -3060,13 +3051,12 @@ static void prefix_patches(struct patch *p)
30603051static int apply_patch (int fd , const char * filename , int options )
30613052{
30623053 size_t offset ;
3063- struct strbuf buf ;
3054+ struct strbuf buf = STRBUF_INIT ;
30643055 struct patch * list = NULL , * * listp = & list ;
30653056 int skipped_patch = 0 ;
30663057
30673058 /* FIXME - memory leak when using multiple patch files as inputs */
30683059 memset (& fn_table , 0 , sizeof (struct string_list ));
3069- strbuf_init (& buf , 0 );
30703060 patch_input_file = filename ;
30713061 read_patch_file (& buf , fd );
30723062 offset = 0 ;
0 commit comments