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:
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));
|
xbps_humanize_number(size, (int64_t)xbps_data_size(obj));
|
||||||
printf("%s%s%s%s: %s\n", indent, bold, keyname, reset, size);
|
printf("%s%s%s%s: %s\n", indent, bold, keyname, reset, size);
|
||||||
} else {
|
} else {
|
||||||
FILE *f;
|
fwrite(xbps_data_data_nocopy(obj), 1, xbps_data_size(obj), stdout);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user