diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/allocator.c | 4 | ||||
-rw-r--r-- | src/heap-monitor.c | 10 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/allocator.c b/src/allocator.c index 347aa0c..829f519 100644 --- a/src/allocator.c +++ b/src/allocator.c @@ -150,6 +150,10 @@ void *allocator_alloc(struct allocator *handle, int size) break; } } while ((tmp = tmp->next) && tmp != handle->used); + + if (!tmp) { + tmp = handle->used; + } } tmp->prev->next = chunk; diff --git a/src/heap-monitor.c b/src/heap-monitor.c index 5e91cec..7908c08 100644 --- a/src/heap-monitor.c +++ b/src/heap-monitor.c @@ -404,6 +404,7 @@ API void *realloc(void *__ptr, size_t size) if (!size) { free(__ptr); + return NULL; } else if (!__ptr) { return malloc(size); } @@ -559,7 +560,14 @@ API int posix_memalign(void **memptr, size_t alignment, size_t size) API void *vmalloc(size_t size) { - return memalign(sysconf(_SC_PAGESIZE), size); + int pagesz; + + pagesz = sysconf(_SC_PAGESIZE); + if (pagesz < 0) { + ErrPrint("%s\n", strerror(errno)); + pagesz = 4096; + } + return memalign(pagesz, size); } static int iterator_cb(struct dl_phdr_info *info, size_t size, void *data) |