bin/xbps-query: use fwrite directly.
Avoids allocations and an unnecessary loop (and printf usage, fputs would have been enough). Closes: #401 [via git-merge-pr]
This commit is contained in:
		
				
					committed by
					
						
						Duncan Overbruck
					
				
			
			
				
	
			
			
			
						parent
						
							08ad0c2a9b
						
					
				
				
					commit
					b18499a62d
				
			@@ -106,17 +106,7 @@ print_value_obj(const char *keyname, xbps_object_t obj,
 | 
			
		||||
			xbps_humanize_number(size, (int64_t)xbps_data_size(obj));
 | 
			
		||||
			printf("%s%s%s%s: %s\n", indent, bold, keyname, reset, size);
 | 
			
		||||
		} else {
 | 
			
		||||
			FILE *f;
 | 
			
		||||
			char buf[BUFSIZ-1];
 | 
			
		||||
			void *data;
 | 
			
		||||
 | 
			
		||||
			data = xbps_data_data(obj);
 | 
			
		||||
			f = fmemopen(data, xbps_data_size(obj), "r");
 | 
			
		||||
			assert(f);
 | 
			
		||||
			while (fgets(buf, sizeof(buf), f))
 | 
			
		||||
				printf("%s", buf);
 | 
			
		||||
			fclose(f);
 | 
			
		||||
			free(data);
 | 
			
		||||
			fwrite(xbps_data_data_nocopy(obj), 1, xbps_data_size(obj), stdout);
 | 
			
		||||
		}
 | 
			
		||||
		break;
 | 
			
		||||
	default:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user