Compare commits
2 Commits
02d60129b1
...
6da93cd854
| Author | SHA1 | Date | |
|---|---|---|---|
| 6da93cd854 | |||
| 4084336705 |
@ -148,3 +148,18 @@ void *urealloc(void *ptr, size_t newsize) {
|
||||
err:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *umallocbig(size_t size) {
|
||||
size_t allocsz = ALIGN_UP(size, 4096);
|
||||
uint8_t *out;
|
||||
int32_t ret = mman_map(NULL, allocsz, MMAN_MAP_PF_RW, 0, &out);
|
||||
if (out == NULL || ret != E_OK) {
|
||||
return NULL;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
void ufreebig(void *addr) {
|
||||
if (addr != NULL)
|
||||
mman_unmap(addr);
|
||||
}
|
||||
|
||||
@ -7,5 +7,7 @@
|
||||
void *umalloc(size_t size);
|
||||
void ufree(void *ptr_);
|
||||
void *urealloc(void *ptr, size_t newsize);
|
||||
void *umallocbig(size_t size);
|
||||
void ufreebig(void *addr);
|
||||
|
||||
#endif // ULIB_UMALLOC_UMALLOC_H_
|
||||
|
||||
@ -21,6 +21,8 @@
|
||||
(_a > _b ? _a : _b); \
|
||||
})
|
||||
|
||||
#define ALIGN_UP(x, align) (((x) + ((align)-1)) & ~((align)-1))
|
||||
|
||||
void quit(void);
|
||||
|
||||
#endif // ULIB_UTIL_UTIL_H_
|
||||
|
||||
@ -60,7 +60,7 @@ void fs_fetch(void) {
|
||||
uint8_t *buf = umalloc(statbuf.size+1);
|
||||
string_memset(buf, 0, statbuf.size+1);
|
||||
|
||||
if (fs_read(h, buf, statbuf.size, 0)) {
|
||||
if (fs_read(h, buf, statbuf.size, 0) < 0) {
|
||||
uprintf("fs: coult not read %s\n", path);
|
||||
goto donefile;
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user