diff options
-rw-r--r-- | packaging/libheap-monitor.spec | 2 | ||||
-rw-r--r-- | src/allocator.c | 4 | ||||
-rw-r--r-- | src/heap-monitor.c | 10 |
3 files changed, 14 insertions, 2 deletions
diff --git a/packaging/libheap-monitor.spec b/packaging/libheap-monitor.spec index 8c1e010..62f162f 100644 --- a/packaging/libheap-monitor.spec +++ b/packaging/libheap-monitor.spec @@ -1,6 +1,6 @@ Name: libheap-monitor Summary: Library for monitoring the heap usage -Version: 0.0.16 +Version: 0.0.17 Release: 1 Group: HomeTF/Livebox License: Flora License 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) |