Convert tests to valid C++ code
authorIvan Maidanski <ivmai@mail.ru>
Thu, 8 Feb 2018 22:12:27 +0000 (01:12 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 5 Mar 2018 21:36:06 +0000 (00:36 +0300)
* tests/test_malloc.c (cons, dummy_test, run_one_test): Add explicit
cast of void* pointer (returned by malloc) to the type of the variable
the pointer is assigned to.
* tests/test_stack.c (add_elements): Likewise.

tests/test_malloc.c
tests/test_stack.c

index a7b36bd..fd95a8f 100644 (file)
@@ -81,7 +81,7 @@ ln *cons(int d, ln *tail)
   int * extras;
   unsigned i;
 
-  result = AO_malloc(sizeof(ln) + sizeof(int)*my_extra);
+  result = (ln *)AO_malloc(sizeof(ln) + sizeof(int)*my_extra);
   if (result == 0)
     {
       fprintf(stderr, "Out of memory\n");
@@ -170,7 +170,7 @@ int dummy_test(void) { return 1; }
 void * run_one_test(void * arg) {
   ln * x = make_list(1, LIST_LENGTH);
   int i;
-  char *p = AO_malloc(LARGE_OBJ_SIZE);
+  char *p = (char *)AO_malloc(LARGE_OBJ_SIZE);
   char *q;
   char a = 'a' + ((int)((AO_PTRDIFF_T)arg) * 2) % ('z' - 'a' + 1);
   char b = a + 1;
@@ -185,7 +185,7 @@ void * run_one_test(void * arg) {
 #   endif
   } else {
     p[0] = p[LARGE_OBJ_SIZE/2] = p[LARGE_OBJ_SIZE-1] = a;
-    q = AO_malloc(LARGE_OBJ_SIZE);
+    q = (char *)AO_malloc(LARGE_OBJ_SIZE);
     if (q == 0)
       {
         fprintf(stderr, "Out of memory\n");
index 5507b54..4edc88b 100644 (file)
@@ -91,7 +91,7 @@ void add_elements(int n)
   list_element * le;
   if (n == 0) return;
   add_elements(n-1);
-  le = malloc(sizeof(list_element));
+  le = (list_element *)malloc(sizeof(list_element));
   if (le == 0)
     {
       fprintf(stderr, "Out of memory\n");