diff options
| author | Jason Evans <jasone@canonware.com> | 2016-05-04 00:34:40 (GMT) |
|---|---|---|
| committer | Jason Evans <jasone@canonware.com> | 2016-05-04 00:34:40 (GMT) |
| commit | e02b83cc5e3c4d30f93dba945162e3aa58d962d6 (patch) | |
| tree | dc1cf37bd624061c6351ea3a78f993d2a19310ac /test/integration/mallocx.c | |
| parent | df900dbfaf4835d3efc06d771535f3e781544913 (diff) | |
| parent | 2e5eb21184cccabc829265b5f5237f3c13563be6 (diff) | |
| download | jemalloc-4.1.1.zip jemalloc-4.1.1.tar.gz jemalloc-4.1.1.tar.bz2 | |
Merge branch.4.1.1
Diffstat (limited to 'test/integration/mallocx.c')
| -rw-r--r-- | test/integration/mallocx.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/test/integration/mallocx.c b/test/integration/mallocx.c index 42eee10..c185cc6 100644 --- a/test/integration/mallocx.c +++ b/test/integration/mallocx.c @@ -70,22 +70,27 @@ TEST_END TEST_BEGIN(test_oom) { size_t hugemax, size, alignment; - - hugemax = get_huge_size(get_nhuge()-1); + bool oom; + void *ptrs[3]; + unsigned i; /* - * It should be impossible to allocate two objects that each consume - * more than half the virtual address space. + * It should be impossible to allocate three objects that each consume + * nearly half the virtual address space. */ - { - void *p; - - p = mallocx(hugemax, 0); - if (p != NULL) { - assert_ptr_null(mallocx(hugemax, 0), - "Expected OOM for mallocx(size=%#zx, 0)", hugemax); - dallocx(p, 0); - } + hugemax = get_huge_size(get_nhuge()-1); + oom = false; + for (i = 0; i < sizeof(ptrs) / sizeof(void *); i++) { + ptrs[i] = mallocx(hugemax, 0); + if (ptrs[i] == NULL) + oom = true; + } + assert_true(oom, + "Expected OOM during series of calls to mallocx(size=%zu, 0)", + hugemax); + for (i = 0; i < sizeof(ptrs) / sizeof(void *); i++) { + if (ptrs[i] != NULL) + dallocx(ptrs[i], 0); } #if LG_SIZEOF_PTR == 3 |
