gcc/gcc/varray.c
Joseph Myers 961192e1dd alias.c [...] (init_alias_analysis, [...]): Use memset () instead of bzero ().
* alias.c (init_alias_analysis), calls.c (expand_call,
	emit_library_call_value_1), combine.c (init_reg_last_arrays),
	cse.c (new_basic_block), dbxout.c (dbxout_type), diagnostic.c
	(init_output_buffer, set_diagnostic_context), dwarf2out.c
	(equate_decl_number_to_die, build_abbrev_table), emit-rtl.c
	(init_emit_once), fold-const.c (mul_double, div_and_round_double),
	function.c (assign_parms), gcse.c (compute_can_copy,
	alloc_gcse_mem, alloc_reg_set_mem, record_one_set,
	compute_hash_table, compute_set_hash_table,
	compute_expr_hash_table), genattrtab.c (optimize_attrs), global.c
	(global_alloc, global_conflicts), haifa-sched.c (compute_trg_info,
	clear_units, schedule_block), integrate.c (initialize_for_inline,
	expand_inline_function), jump.c (thread_jumps), local-alloc.c
	(local_alloc), loop.c (combine_movables, count_loop_regs_set,
	load_mems_and_recount_loop_regs_set), print-tree.c (debug_tree),
	regclass.c (init_reg_sets, init_reg_sets_1, regclass,
	record_reg_classes, allocate_reg_info), reload.c
	(get_secondary_mem, remove_address_replacements, find_reloads),
	reload1.c (reload, set_initial_label_offsets, finish_spills,
	reload_as_needed, choose_reload_regs_init,
	reload_cse_simplify_operands), reorg.c (dbr_schedule), sbitmap.c
	(sbitmap_zero), simplify-rtx.c (simplify_plus_minus), ssa.c
	(rename_registers), stmt.c (expand_end_case), unroll.c
	(unroll_loop), varray.c (varray_grow), objc/objc-act.c: Use memset
	() instead of bzero ().

ch:
	* actions.c (check_missing_cases), typeck.c (build_chill_slice,
	build_chill_cast): Use memset () instead of bzero ().

cp:
	* class.c (duplicate_tag_error, build_vtbl_initializer), decl.c
	(push_binding_level), error.c (cp_tree_printer), pt.c
	(process_partial_specialization, tsubst_template_arg_vector),
	search.c (lookup_member): Use memset () instead of bzero ().

java:
	* expr.c (note_instructions), jcf-io.c (find_class), jcf-parse.c
	(init_outgoing_cpool), lex.c (java_init_lex): Use memset ()
	instead of bzero ().

From-SVN: r37303
2000-11-07 22:50:06 +00:00

93 lines
2.7 KiB
C

/* Virtual array support.
Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
Contributed by Cygnus Solutions.
This file is part of GNU CC.
GNU CC is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU CC is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU CC; see the file COPYING. If not, write to the Free
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include "config.h"
#include "system.h"
#include "rtl.h"
#include "tree.h"
#include "bitmap.h"
#include "varray.h"
#define VARRAY_HDR_SIZE (sizeof (struct varray_head_tag) - sizeof (varray_data))
/* Allocate a virtual array with NUM_ELEMENT elements, each of which is
ELEMENT_SIZE bytes long, named NAME. Array elements are zeroed. */
varray_type
varray_init (num_elements, element_size, name)
size_t num_elements;
size_t element_size;
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;
ptr->element_size = element_size;
ptr->name = name;
return ptr;
}
/* Grow/shrink the virtual array VA to N elements. Zero any new elements
allocated. */
varray_type
varray_grow (va, n)
varray_type va;
size_t n;
{
size_t old_elements = va->num_elements;
if (n != old_elements)
{
size_t element_size = va->element_size;
size_t old_data_size = old_elements * element_size;
size_t data_size = n * element_size;
va = (varray_type) xrealloc ((char *)va, VARRAY_HDR_SIZE + data_size);
va->num_elements = n;
if (n > old_elements)
memset (&va->data.c[old_data_size], 0, data_size - old_data_size);
}
return va;
}
/* Check the bounds of a varray access. */
#if defined ENABLE_CHECKING && (GCC_VERSION >= 2007)
extern void error PARAMS ((const char *, ...)) ATTRIBUTE_PRINTF_1;
void
varray_check_failed (va, n, file, line, function)
varray_type va;
size_t n;
const char *file;
int line;
const char *function;
{
error("Virtual array %s[%lu]: element %lu out of bounds",
va->name, (unsigned long) va->num_elements, (unsigned long) n);
fancy_abort (file, line, function);
}
#endif