]> granicus.if.org Git - libatomic_ops/commitdiff
2011-06-03 Ivan Maidanski <ivmai@mail.ru>
authorivmai <ivmai>
Fri, 3 Jun 2011 13:25:31 +0000 (13:25 +0000)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 25 Jul 2011 12:03:26 +0000 (16:03 +0400)
* tests/test_malloc.c (run_one_test): Test AO_malloc() result
(if out of memory then print the message and abort).
* tests/test_stack.c (add_elements): Ditto.

ChangeLog
tests/test_malloc.c
tests/test_stack.c

index c4b963db0403d3193364f396aa5d2acb229975b4..42883eb7c8aba14f0fb1ede6a3f9e4983798a122 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-06-03  Ivan Maidanski  <ivmai@mail.ru>
+
+       * tests/test_malloc.c (run_one_test): Test AO_malloc() result
+       (if out of memory then print the message and abort).
+       * tests/test_stack.c (add_elements): Ditto.
+
 2011-06-03  Ivan Maidanski  <ivmai@mail.ru>
 
        * src/atomic_ops/generalize.h (AO_HAVE_or_full): Add missing
index f7df3428b6c2ba0b9907c04d3d85b9fc3eadb847..4bf6e6c8958fa60e7bc9b586eb31bc2690438215 100644 (file)
@@ -150,6 +150,12 @@ void * run_one_test(void * arg) {
   } else {
     p[0] = p[LARGE_OBJ_SIZE/2] = p[LARGE_OBJ_SIZE-1] = 'a';
     q = AO_malloc(LARGE_OBJ_SIZE);
+    if (q == 0)
+      {
+        fprintf(stderr, "Out of memory\n");
+          /* Normal for more than about 10 threads without mmap? */
+        abort();
+      }
     q[0] = q[LARGE_OBJ_SIZE/2] = q[LARGE_OBJ_SIZE-1] = 'b';
     if (p[0] != 'a' || p[LARGE_OBJ_SIZE/2] != 'a'
         || p[LARGE_OBJ_SIZE-1] != 'a') {
index a190a78f64605e73a2dce233d4030d1e2faa2033..a51d24492c4c8b92986590bc92602f5abee041c0 100644 (file)
@@ -54,6 +54,11 @@ void add_elements(int n)
   if (n == 0) return;
   add_elements(n-1);
   le = malloc(sizeof(list_element));
+  if (le == 0)
+    {
+      fprintf(stderr, "Out of memory\n");
+      abort();
+    }
   le -> data = n;
   AO_stack_push(&the_list, (AO_t *)le);
 }