Use dynamic_bitset.emplace_back()

This commit is contained in:
topjohnwu 2022-02-11 01:00:58 -08:00
parent f6d765bf81
commit 55ed6109c1
2 changed files with 15 additions and 12 deletions

View File

@ -93,6 +93,9 @@ public:
slot_type get_slot(size_t slot) const { slot_type get_slot(size_t slot) const {
return slot_list.size() > slot ? slot_list[slot].to_ulong() : 0ul; return slot_list.size() > slot ? slot_list[slot].to_ulong() : 0ul;
} }
void emplace_back(slot_type l) {
slot_list.emplace_back(l);
}
protected: protected:
slot_bits::reference get(size_t pos) { slot_bits::reference get(size_t pos) {
size_t slot = pos / slot_size; size_t slot = pos / slot_size;

View File

@ -367,21 +367,21 @@ static void get_process_info(int client, const sock_cred *cred) {
// Collect module status from system_server // Collect module status from system_server
int slots = read_int(client); int slots = read_int(client);
int id = 0; dynamic_bitset bits;
for (int i = 0; i < slots; ++i) { for (int i = 0; i < slots; ++i) {
dynamic_bitset::slot_type l = 0; dynamic_bitset::slot_type l = 0;
xxread(client, &l, sizeof(l)); xxread(client, &l, sizeof(l));
dynamic_bitset::slot_bits bits(l); bits.emplace_back(l);
for (int j = 0; id < module_list->size(); ++j, ++id) { }
if (!bits[j]) { for (int id = 0; id < module_list->size(); ++id) {
// Either not a zygisk module, or incompatible if (!as_const(bits)[id]) {
char buf[4096]; // Either not a zygisk module, or incompatible
snprintf(buf, sizeof(buf), MODULEROOT "/%s/zygisk", char buf[4096];
module_list->operator[](id).name.data()); snprintf(buf, sizeof(buf), MODULEROOT "/%s/zygisk",
if (int dirfd = open(buf, O_RDONLY | O_CLOEXEC); dirfd >= 0) { module_list->operator[](id).name.data());
close(xopenat(dirfd, "unloaded", O_CREAT | O_RDONLY, 0644)); if (int dirfd = open(buf, O_RDONLY | O_CLOEXEC); dirfd >= 0) {
close(dirfd); close(xopenat(dirfd, "unloaded", O_CREAT | O_RDONLY, 0644));
} close(dirfd);
} }
} }
} }