 d0732a8120
			
		
	
	d0732a8120
	
	
	
		
			
			More work towards -Wunused. * jk/unused-post-2.39-part2: (21 commits) help: mark unused parameter in git_unknown_cmd_config() run_processes_parallel: mark unused callback parameters userformat_want_item(): mark unused parameter for_each_commit_graft(): mark unused callback parameter rewrite_parents(): mark unused callback parameter fetch-pack: mark unused parameter in callback function notes: mark unused callback parameters prio-queue: mark unused parameters in comparison functions for_each_object: mark unused callback parameters list-objects: mark unused callback parameters mark unused parameters in signal handlers run-command: mark error routine parameters as unused mark "pointless" data pointers in callbacks ref-filter: mark unused callback parameters http-backend: mark unused parameters in virtual functions http-backend: mark argc/argv unused object-name: mark unused parameters in disambiguate callbacks serve: mark unused parameters in virtual functions serve: use repository pointer to get config ls-refs: drop config caching ...
		
			
				
	
	
		
			52 lines
		
	
	
		
			987 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			52 lines
		
	
	
		
			987 B
		
	
	
	
		
			C
		
	
	
	
	
	
| #include "test-tool.h"
 | |
| #include "prio-queue.h"
 | |
| 
 | |
| static int intcmp(const void *va, const void *vb, void *data UNUSED)
 | |
| {
 | |
| 	const int *a = va, *b = vb;
 | |
| 	return *a - *b;
 | |
| }
 | |
| 
 | |
| static void show(int *v)
 | |
| {
 | |
| 	if (!v)
 | |
| 		printf("NULL\n");
 | |
| 	else
 | |
| 		printf("%d\n", *v);
 | |
| 	free(v);
 | |
| }
 | |
| 
 | |
| int cmd__prio_queue(int argc, const char **argv)
 | |
| {
 | |
| 	struct prio_queue pq = { intcmp };
 | |
| 
 | |
| 	while (*++argv) {
 | |
| 		if (!strcmp(*argv, "get")) {
 | |
| 			void *peek = prio_queue_peek(&pq);
 | |
| 			void *get = prio_queue_get(&pq);
 | |
| 			if (peek != get)
 | |
| 				BUG("peek and get results do not match");
 | |
| 			show(get);
 | |
| 		} else if (!strcmp(*argv, "dump")) {
 | |
| 			void *peek;
 | |
| 			void *get;
 | |
| 			while ((peek = prio_queue_peek(&pq))) {
 | |
| 				get = prio_queue_get(&pq);
 | |
| 				if (peek != get)
 | |
| 					BUG("peek and get results do not match");
 | |
| 				show(get);
 | |
| 			}
 | |
| 		} else if (!strcmp(*argv, "stack")) {
 | |
| 			pq.compare = NULL;
 | |
| 		} else {
 | |
| 			int *v = xmalloc(sizeof(*v));
 | |
| 			*v = atoi(*argv);
 | |
| 			prio_queue_put(&pq, v);
 | |
| 		}
 | |
| 	}
 | |
| 
 | |
| 	clear_prio_queue(&pq);
 | |
| 
 | |
| 	return 0;
 | |
| }
 |