This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
fix xcalloc argument order
- To: gcc-patches at gcc dot gnu dot org
- Subject: fix xcalloc argument order
- From: Matt Kraai <kraai at alumni dot carnegiemellon dot edu>
- Date: Mon, 12 Mar 2001 12:16:01 -0700
Howdy,
The following patch makes calls to xcalloc pass parameters in the
correct order (i.e., the number of elements followed by size of
each element).
Matt
For gcc/ChangeLog
2001-03-13 Matt Kraai <kraai@alumni.carnegiemellon.edu>
* collect2.c (main, add_to_list, scan_prog_file, read_file): Fix
xcalloc argument order.
* gcc.c (init_spec, main): Likewise.
* gcov.c (output_data): Likewise.
* regclass.c (allocate_reg_info): Likewise.
* reload1.c (init_elim_table): Likewise.
* varray.c (varray_init): Likewise.
For gcc/ch/ChangeLog:
2001-03-13 Matt Kraai <kraai@alumni.carnegiemellon.edu>
* decl.c (init_decl_processing): Fix xcalloc argument order.
For gcc/cp/ChangeLog:
2001-03-13 Matt Kraai <kraai@alumni.carnegiemellon.edu>
* lex.c (init_cpp_parse): Fix xcalloc argument order.
Index: collect2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/collect2.c,v
retrieving revision 1.107
diff -c -3 -p -r1.107 collect2.c
*** collect2.c 2001/01/25 20:12:30 1.107
--- collect2.c 2001/03/12 19:05:23
*************** main (argc, argv)
*** 885,893 ****
/* Do not invoke xcalloc before this point, since locale needs to be
set first, in case a diagnostic is issued. */
! ld1 = (const char **)(ld1_argv = (char **) xcalloc(sizeof (char *), argc+3));
! ld2 = (const char **)(ld2_argv = (char **) xcalloc(sizeof (char *), argc+10));
! object = (const char **)(object_lst = (char **) xcalloc(sizeof (char *), argc));
#ifdef DEBUG
debug = 1;
--- 885,893 ----
/* Do not invoke xcalloc before this point, since locale needs to be
set first, in case a diagnostic is issued. */
! ld1 = (const char **)(ld1_argv = (char **) xcalloc(argc+3, sizeof (char *)));
! ld2 = (const char **)(ld2_argv = (char **) xcalloc(argc+10, sizeof (char *)));
! object = (const char **)(object_lst = (char **) xcalloc(argc, sizeof (char *)));
#ifdef DEBUG
debug = 1;
*************** main (argc, argv)
*** 929,935 ****
num_c_args += 2;
c_ptr = (const char **)
! (c_argv = (char **) xcalloc (sizeof (char *), num_c_args));
if (argc < 2)
fatal ("no arguments");
--- 929,935 ----
num_c_args += 2;
c_ptr = (const char **)
! (c_argv = (char **) xcalloc (num_c_args, sizeof (char *)));
if (argc < 2)
fatal ("no arguments");
*************** main (argc, argv)
*** 1404,1410 ****
/* Strip now if it was requested on the command line. */
if (strip_flag)
{
! char **real_strip_argv = (char **) xcalloc (sizeof (char *), 3);
const char ** strip_argv = (const char **) real_strip_argv;
strip_argv[0] = strip_file_name;
--- 1404,1410 ----
/* Strip now if it was requested on the command line. */
if (strip_flag)
{
! char **real_strip_argv = (char **) xcalloc (3, sizeof (char *));
const char ** strip_argv = (const char **) real_strip_argv;
strip_argv[0] = strip_file_name;
*************** add_to_list (head_ptr, name)
*** 1669,1675 ****
const char *name;
{
struct id *newid
! = (struct id *) xcalloc (sizeof (struct id) + strlen (name), 1);
struct id *p;
strcpy (newid->name, name);
--- 1669,1675 ----
const char *name;
{
struct id *newid
! = (struct id *) xcalloc (1, sizeof (struct id) + strlen (name));
struct id *p;
strcpy (newid->name, name);
*************** scan_prog_file (prog_name, which_pass)
*** 3077,3083 ****
offset = hdr.moh_first_cmd_off;
load_end = load_array
! = (load_all_t *) xcalloc (sizeof (load_all_t), hdr.moh_n_load_cmds + 2);
/* Build array of load commands, calculating the offsets */
for (i = 0; i < hdr.moh_n_load_cmds; i++)
--- 3077,3083 ----
offset = hdr.moh_first_cmd_off;
load_end = load_array
! = (load_all_t *) xcalloc (hdr.moh_n_load_cmds + 2, sizeof (load_all_t));
/* Build array of load commands, calculating the offsets */
for (i = 0; i < hdr.moh_n_load_cmds; i++)
*************** read_file (name, fd, rw)
*** 3510,3516 ****
int rw; /* read/write */
{
struct stat stat_pkt;
! struct file_info *p = (struct file_info *) xcalloc (sizeof (struct file_info), 1);
#ifdef USE_MMAP
static int page_size;
#endif
--- 3510,3516 ----
int rw; /* read/write */
{
struct stat stat_pkt;
! struct file_info *p = (struct file_info *) xcalloc (1, sizeof (struct file_info));
#ifdef USE_MMAP
static int page_size;
#endif
Index: gcc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcc.c,v
retrieving revision 1.215
diff -c -3 -p -r1.215 gcc.c
*** gcc.c 2001/03/08 23:33:58 1.215
--- gcc.c 2001/03/12 19:05:24
*************** init_spec ()
*** 1346,1352 ****
#ifdef EXTRA_SPECS
extra_specs = (struct spec_list *)
! xcalloc (sizeof (struct spec_list), ARRAY_SIZE (extra_specs_1));
for (i = ARRAY_SIZE (extra_specs_1) - 1; i >= 0; i--)
{
--- 1346,1352 ----
#ifdef EXTRA_SPECS
extra_specs = (struct spec_list *)
! xcalloc (ARRAY_SIZE (extra_specs_1), sizeof (struct spec_list));
for (i = ARRAY_SIZE (extra_specs_1) - 1; i >= 0; i--)
{
*************** main (argc, argv)
*** 5863,5869 ****
/* Record which files were specified explicitly as link input. */
! explicit_link_files = xcalloc (1, n_infiles);
for (i = 0; (int) i < n_infiles; i++)
{
--- 5863,5869 ----
/* Record which files were specified explicitly as link input. */
! explicit_link_files = xcalloc (n_infiles, 1);
for (i = 0; (int) i < n_infiles; i++)
{
Index: gcov.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcov.c,v
retrieving revision 1.29
diff -c -3 -p -r1.29 gcov.c
*** gcov.c 2000/12/17 14:35:05 1.29
--- gcov.c 2001/03/12 19:05:24
*************** output_data ()
*** 1035,1045 ****
else
source_file_name = s_ptr->name;
! line_counts = (long *) xcalloc (sizeof (long), s_ptr->maxlineno);
! line_exists = xcalloc (1, s_ptr->maxlineno);
if (output_branch_probs)
branch_probs = (struct arcdata **)
! xcalloc (sizeof (struct arcdata *), s_ptr->maxlineno);
/* There will be a zero at the beginning of the bb info, before the
first list of line numbers, so must initialize block_num to 0. */
--- 1035,1045 ----
else
source_file_name = s_ptr->name;
! line_counts = (long *) xcalloc (s_ptr->maxlineno, sizeof (long));
! line_exists = xcalloc (s_ptr->maxlineno, 1);
if (output_branch_probs)
branch_probs = (struct arcdata **)
! xcalloc (s_ptr->maxlineno, sizeof (struct arcdata *));
/* There will be a zero at the beginning of the bb info, before the
first list of line numbers, so must initialize block_num to 0. */
Index: regclass.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/regclass.c,v
retrieving revision 1.117
diff -c -3 -p -r1.117 regclass.c
*** regclass.c 2001/03/02 21:41:36 1.117
--- regclass.c 2001/03/12 19:05:24
*************** allocate_reg_info (num_regs, new_p, renu
*** 2146,2152 ****
size_info = (regno_allocated - old_allocated) * sizeof (reg_info)
+ sizeof (struct reg_info_data) - sizeof (reg_info);
! reg_data = (struct reg_info_data *) xcalloc (size_info, 1);
reg_data->min_index = old_allocated;
reg_data->max_index = regno_allocated - 1;
reg_data->next = reg_info_head;
--- 2146,2152 ----
size_info = (regno_allocated - old_allocated) * sizeof (reg_info)
+ sizeof (struct reg_info_data) - sizeof (reg_info);
! reg_data = (struct reg_info_data *) xcalloc (1, size_info);
reg_data->min_index = old_allocated;
reg_data->max_index = regno_allocated - 1;
reg_data->next = reg_info_head;
Index: reload1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/reload1.c,v
retrieving revision 1.259
diff -c -3 -p -r1.259 reload1.c
*** reload1.c 2001/03/12 04:30:56 1.259
--- reload1.c 2001/03/12 19:05:25
*************** init_elim_table ()
*** 3484,3490 ****
if (!reg_eliminate)
reg_eliminate = (struct elim_table *)
! xcalloc (sizeof (struct elim_table), NUM_ELIMINABLE_REGS);
/* Does this function require a frame pointer? */
--- 3484,3490 ----
if (!reg_eliminate)
reg_eliminate = (struct elim_table *)
! xcalloc (NUM_ELIMINABLE_REGS, sizeof (struct elim_table));
/* Does this function require a frame pointer? */
Index: varray.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/varray.c,v
retrieving revision 1.9
diff -c -3 -p -r1.9 varray.c
*** varray.c 2000/11/07 22:49:54 1.9
--- varray.c 2001/03/12 19:05:25
*************** varray_init (num_elements, element_size,
*** 37,43 ****
const char *name;
{
size_t data_size = num_elements * element_size;
! varray_type ptr = (varray_type) xcalloc (VARRAY_HDR_SIZE + data_size, 1);
ptr->num_elements = num_elements;
ptr->elements_used = 0;
--- 37,43 ----
const char *name;
{
size_t data_size = num_elements * element_size;
! varray_type ptr = (varray_type) xcalloc (1, VARRAY_HDR_SIZE + data_size);
ptr->num_elements = num_elements;
ptr->elements_used = 0;
Index: ch/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ch/decl.c,v
retrieving revision 1.31
diff -c -3 -p -r1.31 decl.c
*** decl.c 2001/02/23 20:38:55 1.31
--- decl.c 2001/03/12 19:05:25
*************** init_decl_processing ()
*** 3514,3521 ****
chill_tree_code_name,
(((int) LAST_CHILL_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
* sizeof (char *)));
! boolean_code_name = (const char **) xcalloc (sizeof (char *),
! (int) LAST_CHILL_TREE_CODE);
boolean_code_name[EQ_EXPR] = "=";
boolean_code_name[NE_EXPR] = "/=";
--- 3514,3521 ----
chill_tree_code_name,
(((int) LAST_CHILL_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
* sizeof (char *)));
! boolean_code_name = (const char **) xcalloc ((int) LAST_CHILL_TREE_CODE,
! sizeof (char *));
boolean_code_name[EQ_EXPR] = "=";
boolean_code_name[NE_EXPR] = "/=";
Index: cp/lex.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/lex.c,v
retrieving revision 1.238
diff -c -3 -p -r1.238 lex.c
*** lex.c 2001/03/10 16:33:57 1.238
--- lex.c 2001/03/12 19:05:25
*************** init_cpp_parse ()
*** 297,305 ****
{
#ifdef GATHER_STATISTICS
#ifdef REDUCE_LENGTH
! reduce_count = (int *) xcalloc (sizeof (int), (REDUCE_LENGTH + 1));
reduce_count += 1;
! token_count = (int *) xcalloc (sizeof (int), (TOKEN_LENGTH + 1));
token_count += 1;
#endif
#endif
--- 297,305 ----
{
#ifdef GATHER_STATISTICS
#ifdef REDUCE_LENGTH
! reduce_count = (int *) xcalloc ((REDUCE_LENGTH + 1), sizeof (int));
reduce_count += 1;
! token_count = (int *) xcalloc ((TOKEN_LENGTH + 1), sizeof (int));
token_count += 1;
#endif
#endif