@@ -312,14 +312,15 @@ EmbeddedAssemblies::zip_load_assembly_store_entries (std::span<uint8_t> const& b
312
312
}
313
313
}
314
314
315
+ [[gnu::flatten]]
315
316
void
316
317
EmbeddedAssemblies::zip_load_entries (int fd, const char *apk_name, [[maybe_unused]] monodroid_should_register should_register)
317
318
{
318
319
uint32_t cd_offset;
319
320
uint32_t cd_size;
320
321
uint16_t cd_entries;
321
322
322
- if (!zip_read_cd_info (fd, cd_offset, cd_size, cd_entries)) {
323
+ if (!zip_read_cd_info (fd, cd_offset, cd_size, cd_entries)) [[unlikely]] {
323
324
Helpers::abort_application (
324
325
LOG_ASSEMBLY,
325
326
Util::monodroid_strdup_printf (
@@ -329,14 +330,12 @@ EmbeddedAssemblies::zip_load_entries (int fd, const char *apk_name, [[maybe_unus
329
330
);
330
331
}
331
332
332
- md_mmap_info apk_map = md_mmap_apk_file (fd, cd_offset, cd_size, apk_name);
333
-
334
333
log_debug (LOG_ASSEMBLY, " Central directory offset: %u" , cd_offset);
335
334
log_debug (LOG_ASSEMBLY, " Central directory size: %u" , cd_size);
336
335
log_debug (LOG_ASSEMBLY, " Central directory entries: %u" , cd_entries);
337
336
338
337
// off_t retval = ::lseek (fd, static_cast<off_t>(cd_offset), SEEK_SET);
339
- // if (retval < 0) {
338
+ // if (retval < 0) [[unlikely]] {
340
339
// Helpers::abort_application (
341
340
// LOG_ASSEMBLY,
342
341
// Util::monodroid_strdup_printf (
@@ -349,7 +348,6 @@ EmbeddedAssemblies::zip_load_entries (int fd, const char *apk_name, [[maybe_unus
349
348
// );
350
349
// }
351
350
352
- std::span<uint8_t > buf (reinterpret_cast <uint8_t *>(apk_map.area ), apk_map.size );
353
351
const auto [prefix, prefix_len] = get_assemblies_prefix_and_length ();
354
352
ZipEntryLoadState state {
355
353
.file_fd = fd,
@@ -366,29 +364,30 @@ EmbeddedAssemblies::zip_load_entries (int fd, const char *apk_name, [[maybe_unus
366
364
.max_assembly_file_name_size = 0 ,
367
365
};
368
366
369
- // ssize_t nread = read (fd, buf.data (), static_cast<read_count_type>(buf.size ()));
370
- // if (static_cast<size_t>(nread) != cd_size) {
371
- // log_fatal (LOG_ASSEMBLY, "Failed to read Central Directory from the APK archive %s. %s (nread: %d; errno: %d)", apk_name, std::strerror (errno), nread, errno);
372
- // Helpers::abort_application ();
373
- // Helpers::abort_application (
374
- // LOG_ASSEMBLY,
375
- // Util::monodroid_strdup_printf (
376
- // "Failed to read Central Directory from APK: %s. nread=%d errno=%d File=%s",
377
- // std::strerror (errno),
378
- // nread,
379
- // errno,
380
- // apk_name
381
- // )
382
- // );
383
- // }
367
+ std::unique_ptr<uint8_t []> raw_data (new uint8_t [cd_size]);
368
+ // auto raw_data = new uint8_t[cd_size];
369
+ std::span<uint8_t > buf (raw_data.get (), cd_size);
370
+ ssize_t nread = read (fd, buf.data (), static_cast <read_count_type>(buf.size ()));
371
+ if (static_cast <size_t >(nread) != cd_size) [[unlikely]] {
372
+ Helpers::abort_application (
373
+ LOG_ASSEMBLY,
374
+ Util::monodroid_strdup_printf (
375
+ " Failed to read Central Directory from APK: %s. nread=%d errno=%d File=%s" ,
376
+ std::strerror (errno),
377
+ nread,
378
+ errno,
379
+ apk_name
380
+ )
381
+ );
382
+ }
384
383
385
384
if (application_config.have_assembly_store ) {
386
385
zip_load_assembly_store_entries (buf, cd_entries, state);
387
386
} else {
388
387
zip_load_individual_assembly_entries (buf, cd_entries, should_register, state);
389
388
}
390
389
391
- // TODO: unmap here
390
+ // delete[] raw_data;
392
391
}
393
392
394
393
template <bool NeedsNameAlloc>
0 commit comments