file: Make sure file buffers are aligned and of the right type

This commit is contained in:
mintsuki 2021-01-02 23:05:30 +01:00
parent 79a9f31ceb
commit 717af1ff87
5 changed files with 2 additions and 2 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -81,7 +81,7 @@ void *freadall(struct file_handle *fd, uint32_t type) {
memmap_alloc_range((uint64_t)(size_t)fd->fd, fd->size, type, false); memmap_alloc_range((uint64_t)(size_t)fd->fd, fd->size, type, false);
return fd->fd; return fd->fd;
} else { } else {
void *ret = ext_mem_alloc(fd->size); void *ret = ext_mem_alloc_aligned_type(fd->size, 4096, type);
if (fd->read(fd->fd, ret, 0, fd->size)) { if (fd->read(fd->fd, ret, 0, fd->size)) {
panic("freadall error"); panic("freadall error");
} }

View File

@ -209,7 +209,7 @@ bool uri_open(struct file_handle *fd, char *uri) {
if (compressed && ret) { if (compressed && ret) {
struct file_handle compressed_fd = {0}; struct file_handle compressed_fd = {0};
fread(fd, &compressed_fd.size, fd->size - 4, sizeof(uint32_t)); fread(fd, &compressed_fd.size, fd->size - 4, sizeof(uint32_t));
compressed_fd.fd = ext_mem_alloc(compressed_fd.size); compressed_fd.fd = ext_mem_alloc_aligned(compressed_fd.size, 4096);
void *src = ext_mem_alloc(fd->size); void *src = ext_mem_alloc(fd->size);
fread(fd, src, 0, fd->size); fread(fd, src, 0, fd->size);
if (tinf_gzip_uncompress(compressed_fd.fd, src, fd->size)) if (tinf_gzip_uncompress(compressed_fd.fd, src, fd->size))