Use smart pointers

This commit is contained in:
topjohnwu
2019-11-23 04:57:52 -05:00
parent 5bee1c56a9
commit 01253f050a
8 changed files with 87 additions and 81 deletions

View File

@@ -174,19 +174,20 @@ int compile_split_cil() {
}
int dump_policydb(const char *file) {
struct policy_file pf;
policy_file_init(&pf);
uint8_t *data;
size_t len;
pf.type = PF_USE_STDIO;
pf.fp = open_stream<byte_stream>(data, len);
if (policydb_write(magisk_policydb, &pf)) {
LOGE("Fail to create policy image\n");
return 1;
{
auto fp = make_stream<byte_stream>(data, len);
struct policy_file pf;
policy_file_init(&pf);
pf.type = PF_USE_STDIO;
pf.fp = fp.get();
if (policydb_write(magisk_policydb, &pf)) {
LOGE("Fail to create policy image\n");
return 1;
}
}
fclose(pf.fp);
int fd = xopen(file, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644);
if (fd < 0)