Add casts to memory allocation related calls
[deliverable/binutils-gdb.git] / gdb / c-exp.y
index 351505e4fff9982a9d5f956593e389e8472dd631..e37a0b1109afc51fd5ee53ffbd2c02977507817e 100644 (file)
@@ -839,7 +839,7 @@ string_exp:
 
                          vec->type = $1.type;
                          vec->length = $1.length;
-                         vec->ptr = malloc ($1.length + 1);
+                         vec->ptr = (char *) malloc ($1.length + 1);
                          memcpy (vec->ptr, $1.ptr, $1.length + 1);
                        }
 
@@ -849,10 +849,10 @@ string_exp:
                             for convenience.  */
                          char *p;
                          ++$$.len;
-                         $$.tokens = realloc ($$.tokens,
-                                              $$.len * sizeof (struct typed_stoken));
+                         $$.tokens = XRESIZEVEC (struct typed_stoken,
+                                                 $$.tokens, $$.len);
 
-                         p = malloc ($2.length + 1);
+                         p = (char *) malloc ($2.length + 1);
                          memcpy (p, $2.ptr, $2.length + 1);
 
                          $$.tokens[$$.len - 1].type = $2.type;
@@ -1006,7 +1006,7 @@ qualified_name:   TYPENAME COLONCOLON name
                          if (!type_aggregate_p (type))
                            error (_("`%s' is not defined as an aggregate type."),
                                   TYPE_SAFE_NAME (type));
-                         buf = alloca ($4.length + 2);
+                         buf = (char *) alloca ($4.length + 2);
                          tmp_token.ptr = buf;
                          tmp_token.length = $4.length + 1;
                          buf[0] = '~';
@@ -1664,7 +1664,7 @@ name_not_typename :       NAME
 static void
 write_destructor_name (struct parser_state *par_state, struct stoken token)
 {
-  char *copy = alloca (token.length + 1);
+  char *copy = (char *) alloca (token.length + 1);
 
   copy[0] = '~';
   memcpy (&copy[1], token.ptr, token.length);
@@ -1686,7 +1686,7 @@ operator_stoken (const char *op)
   char *buf;
 
   st.length = strlen (operator_string) + strlen (op);
-  buf = malloc (st.length + 1);
+  buf = (char *) malloc (st.length + 1);
   strcpy (buf, operator_string);
   strcat (buf, op);
   st.ptr = buf;
@@ -1771,7 +1771,7 @@ parse_number (struct parser_state *par_state,
   struct type *unsigned_type;
   char *p;
 
-  p = alloca (len);
+  p = (char *) alloca (len);
   memcpy (p, buf, len);
 
   if (parsed_float)
@@ -2399,7 +2399,8 @@ scan_macro_expansion (char *expansion)
 
   /* Copy to the obstack, and then free the intermediate
      expansion.  */
-  copy = obstack_copy0 (&expansion_obstack, expansion, strlen (expansion));
+  copy = (char *) obstack_copy0 (&expansion_obstack, expansion,
+                                strlen (expansion));
   xfree (expansion);
 
   /* Save the old lexptr value, so we can return to it when we're done
@@ -3196,9 +3197,10 @@ yylex (void)
      the FIFO, and delete the other constituent tokens.  */
   if (checkpoint > 0)
     {
-      current.value.sval.ptr = obstack_copy0 (&expansion_obstack,
-                                             current.value.sval.ptr,
-                                             current.value.sval.length);
+      current.value.sval.ptr
+       = (const char *) obstack_copy0 (&expansion_obstack,
+                                       current.value.sval.ptr,
+                                       current.value.sval.length);
 
       VEC_replace (token_and_value, token_fifo, 0, &current);
       if (checkpoint > 1)
@@ -3278,7 +3280,7 @@ c_print_token (FILE *file, int type, YYSTYPE value)
     case CHAR:
     case STRING:
       {
-       char *copy = alloca (value.tsval.length + 1);
+       char *copy = (char *) alloca (value.tsval.length + 1);
 
        memcpy (copy, value.tsval.ptr, value.tsval.length);
        copy[value.tsval.length] = '\0';
This page took 0.028993 seconds and 4 git commands to generate.