Merge branch 'jk/drop-free-refspecs' into maint
Code clean-up. * jk/drop-free-refspecs: remote: drop free_refspecs() functionmaint
						commit
						9451a7b629
					
				
							
								
								
									
										28
									
								
								remote.c
								
								
								
								
							
							
						
						
									
										28
									
								
								remote.c
								
								
								
								
							|  | @ -477,26 +477,6 @@ static void read_config(void) | ||||||
| 	alias_all_urls(); | 	alias_all_urls(); | ||||||
| } | } | ||||||
|  |  | ||||||
| /* |  | ||||||
|  * This function frees a refspec array. |  | ||||||
|  * Warning: code paths should be checked to ensure that the src |  | ||||||
|  *          and dst pointers are always freeable pointers as well |  | ||||||
|  *          as the refspec pointer itself. |  | ||||||
|  */ |  | ||||||
| static void free_refspecs(struct refspec *refspec, int nr_refspec) |  | ||||||
| { |  | ||||||
| 	int i; |  | ||||||
|  |  | ||||||
| 	if (!refspec) |  | ||||||
| 		return; |  | ||||||
|  |  | ||||||
| 	for (i = 0; i < nr_refspec; i++) { |  | ||||||
| 		free(refspec[i].src); |  | ||||||
| 		free(refspec[i].dst); |  | ||||||
| 	} |  | ||||||
| 	free(refspec); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| static struct refspec *parse_refspec_internal(int nr_refspec, const char **refspec, int fetch, int verify) | static struct refspec *parse_refspec_internal(int nr_refspec, const char **refspec, int fetch, int verify) | ||||||
| { | { | ||||||
| 	int i; | 	int i; | ||||||
|  | @ -610,7 +590,7 @@ static struct refspec *parse_refspec_internal(int nr_refspec, const char **refsp | ||||||
| 		 * since it is only possible to reach this point from within | 		 * since it is only possible to reach this point from within | ||||||
| 		 * the for loop above. | 		 * the for loop above. | ||||||
| 		 */ | 		 */ | ||||||
| 		free_refspecs(rs, i+1); | 		free_refspec(i+1, rs); | ||||||
| 		return NULL; | 		return NULL; | ||||||
| 	} | 	} | ||||||
| 	die("Invalid refspec '%s'", refspec[i]); | 	die("Invalid refspec '%s'", refspec[i]); | ||||||
|  | @ -621,7 +601,7 @@ int valid_fetch_refspec(const char *fetch_refspec_str) | ||||||
| 	struct refspec *refspec; | 	struct refspec *refspec; | ||||||
|  |  | ||||||
| 	refspec = parse_refspec_internal(1, &fetch_refspec_str, 1, 1); | 	refspec = parse_refspec_internal(1, &fetch_refspec_str, 1, 1); | ||||||
| 	free_refspecs(refspec, 1); | 	free_refspec(1, refspec); | ||||||
| 	return !!refspec; | 	return !!refspec; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -638,6 +618,10 @@ struct refspec *parse_push_refspec(int nr_refspec, const char **refspec) | ||||||
| void free_refspec(int nr_refspec, struct refspec *refspec) | void free_refspec(int nr_refspec, struct refspec *refspec) | ||||||
| { | { | ||||||
| 	int i; | 	int i; | ||||||
|  |  | ||||||
|  | 	if (!refspec) | ||||||
|  | 		return; | ||||||
|  |  | ||||||
| 	for (i = 0; i < nr_refspec; i++) { | 	for (i = 0; i < nr_refspec; i++) { | ||||||
| 		free(refspec[i].src); | 		free(refspec[i].src); | ||||||
| 		free(refspec[i].dst); | 		free(refspec[i].dst); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Junio C Hamano
						Junio C Hamano