From c3f829c1a6d54e6d2e26dbd09fe8a66e4b9185a9 Mon Sep 17 00:00:00 2001 From: Gabriel Dos Reis Date: Sat, 28 May 2005 15:52:48 +0000 Subject: configure.ac: Check declarations for asprintf and vasprintf. * configure.ac: Check declarations for asprintf and vasprintf. * config.in: Regenerate. * configure: Likewise. * charset.c (conversion_loop): Use XRESIZEVEC. (convert_no_conversion): Likewise. (convert_using_iconv): Likewise. (init_iconv_desc): Cast return value of alloca. (cpp_host_to_exec_charset): Use XNEWVEC. (emit_numeric_escape): Use XRESIZEVEC. (cpp_interpret_string): Use XNEWVEC. (cpp_interpret_string): Use XRESIZEVEC. (_cpp_interpret_identifier): Cast return value of alloca. (_cpp_convert_input): Use XNEWVEC and XRESIZEVEC. * directives.c (glue_header_name): Use XNEWVEC and XRESIZEVEC. (parse_include): Use XNEWVEC. (insert_pragma_entry): Rename local variable "new" to "new_entry". (save_registered_pragmas): Cast return value of xmemdup. (destringize_and_run): Same for alloca. (parse_assertion): Likewise. (do_assert): Cast allocated storage to proper type. (cpp_define): Likewise. (_cpp_define_builtin): Likewise. (cpp_undef): Likewise. (handle_assertion): Likewise. (cpp_push_buffer): Rename local variable "new" to "new_buffer". * expr.c (CPP_UPLUS): Cast value to type cpp_ttype. (CPP_UMINUS): Likewise. (struct cpp_operator): Rename from struct operator. (_cpp_expand_op_stack): Use XRESIZEVEC. * files.c (pch_open_file): Use XNEWVEC. (pch_open_file): Use XRESIZEVEC. (read_file_guts): Use XNEWVEC and XRESIZEVEC. (dir_name_of_file): Use XNEWVEC. (make_cpp_file): Use XCNEW. (make_cpp_dir): Likewise. (allocate_file_hash_entries): USE XNEWVEC. (cpp_included): Cast return value of htab_find_with_hash. (append_file_to_dir): Use XNEWVEC. (read_filename_string): Likewise. Use XRESIZEVEC too. (read_name_map): Cast return value of alloca. Use XRESIZEVEC. (remap_filename): Use XNEWVEC. (struct pchf_entry): Move definition out of struct pchf_data. (_cpp_save_file_entries): Use XCNEWVAR. (_cpp_read_file_entries): Use XNEWVAR. * identifiers.c (alloc_node): Use XOBNEW. * init.c (cpp_create_reader): Use XCNEW. (cpp_init_builtins): Cast of b->value to enum builtin_type. (read_original_directory): Cast return value of alloca. * lex.c (add_line_note): Use XRESIZEVEC. (warn_about_normalization): Use XNEWVEC. (_cpp_lex_direct): Cast node->directive_index to (enum cpp_ttype). (new_buff): Use XNEWVEC. * line-map.c (linemap_add): Use XRESIZEVEC. * macro.c (builtin_macro): Cast return value of alloca. (paste_tokens): Likewise. (expand_arg): Use XNEWVEC and XRESIZEVEC. (_cpp_save_parameter): Use XRESIZEVEC. (create_iso_definition): Cast allocated storage to proper type. (_cpp_create_definition): Likewise. (cpp_macro_definition): Use XRESIZEVEC. * makedepend.c (add_clm): Use XNEW. (add_dir): Likewise. * mkdeps.c (munge): Use XNEWVEC. (deps_init): Use XCNEW. (deps_add_target): Use XRESIZEVEC. (deps_add_default_target): Cast return value of alloca. (deps_add_dep): Use XRESIZEVEC. (deps_add_vpath): Likewise. Use XNEWVEC too. (deps_restore): Likewise. * pch.c (save_idents): Use XNEW and XNEWVEC. (cpp_save_state): Use XNEW. (count_defs): Cast return value of htab_find. (write_defs): Likewise. (cpp_write_pch_deps): Use XNEWVEC. (collect_ht_nodes): Use XRESIZEVEC. (cpp_valid_state): Use XNEWVEC. (save_macros): Use XRESIZEVEC. Cast return value of xmemdup. * symtab.c (ht_create): Use XCNEW. (ht_lookup_with_hash): Cast return value of obstack_copy0. (ht_expand): Use XCNEWVEC. * system.h (HAVE_DESIGNATED_INITIALIZERS): False if __cplusplus. (bool): Do not define if __cplusplus. From-SVN: r100295 --- libcpp/pch.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'libcpp/pch.c') diff --git a/libcpp/pch.c b/libcpp/pch.c index 79900c3..28cafbc 100644 --- a/libcpp/pch.c +++ b/libcpp/pch.c @@ -137,11 +137,11 @@ save_idents (cpp_reader *pfile ATTRIBUTE_UNUSED, cpp_hashnode *hn, void *ss_p) struct cpp_string *sp; unsigned char *text; - sp = xmalloc (sizeof (struct cpp_string)); + sp = XNEW (struct cpp_string); *slot = sp; sp->len = NODE_LEN (hn); - sp->text = text = xmalloc (NODE_LEN (hn)); + sp->text = text = XNEWVEC (unsigned char, NODE_LEN (hn)); memcpy (text, NODE_NAME (hn), NODE_LEN (hn)); } } @@ -193,7 +193,7 @@ int cpp_save_state (cpp_reader *r, FILE *f) { /* Save the list of non-void identifiers for the dependency checking. */ - r->savedstate = xmalloc (sizeof (struct cpp_savedstate)); + r->savedstate = XNEW (struct cpp_savedstate); r->savedstate->definedhash = htab_create (100, cpp_string_hash, cpp_string_eq, NULL); cpp_forall_identifiers (r, save_idents, r->savedstate); @@ -226,7 +226,7 @@ count_defs (cpp_reader *pfile ATTRIBUTE_UNUSED, cpp_hashnode *hn, void *ss_p) news.len = NODE_LEN (hn); news.text = NODE_NAME (hn); - slot = htab_find (ss->definedhash, &news); + slot = (void **) htab_find (ss->definedhash, &news); if (slot == NULL) { ss->hashsize += NODE_LEN (hn) + 1; @@ -265,7 +265,7 @@ write_defs (cpp_reader *pfile ATTRIBUTE_UNUSED, cpp_hashnode *hn, void *ss_p) news.len = NODE_LEN (hn); news.text = NODE_NAME (hn); - slot = htab_find (ss->definedhash, &news); + slot = (void **) htab_find (ss->definedhash, &news); if (slot == NULL) { ss->defs[ss->n_defs] = hn; @@ -310,13 +310,13 @@ cpp_write_pch_deps (cpp_reader *r, FILE *f) ss->n_defs = 0; cpp_forall_identifiers (r, count_defs, ss); - ss->defs = xmalloc (ss->n_defs * sizeof (cpp_hashnode *)); + ss->defs = XNEWVEC (cpp_hashnode *, ss->n_defs); ss->n_defs = 0; cpp_forall_identifiers (r, write_defs, ss); /* Sort the list, copy it into a buffer, and write it out. */ qsort (ss->defs, ss->n_defs, sizeof (cpp_hashnode *), &comp_hashnodes); - definedstrs = ss->definedstrs = xmalloc (ss->hashsize); + definedstrs = ss->definedstrs = XNEWVEC (unsigned char, ss->hashsize); for (i = 0; i < ss->n_defs; ++i) { size_t len = NODE_LEN (ss->defs[i]); @@ -390,7 +390,7 @@ collect_ht_nodes (cpp_reader *pfile ATTRIBUTE_UNUSED, cpp_hashnode *hn, if (nl->n_defs == nl->asize) { nl->asize *= 2; - nl->defs = xrealloc (nl->defs, nl->asize * sizeof (cpp_hashnode *)); + nl->defs = XRESIZEVEC (cpp_hashnode *, nl->defs, nl->asize); } nl->defs[nl->n_defs] = hn; @@ -418,7 +418,7 @@ cpp_valid_state (cpp_reader *r, const char *name, int fd) { struct macrodef_struct m; size_t namebufsz = 256; - unsigned char *namebuf = xmalloc (namebufsz); + unsigned char *namebuf = XNEWVEC (unsigned char, namebufsz); unsigned char *undeftab = NULL; struct ht_node_list nl = { 0, 0, 0 }; unsigned char *first, *last; @@ -450,7 +450,7 @@ cpp_valid_state (cpp_reader *r, const char *name, int fd) { free (namebuf); namebufsz = m.definition_length + 256; - namebuf = xmalloc (namebufsz); + namebuf = XNEWVEC (unsigned char, namebufsz); } if ((size_t)read (fd, namebuf, m.definition_length) @@ -488,14 +488,14 @@ cpp_valid_state (cpp_reader *r, const char *name, int fd) /* Read in the list of identifiers that must not be defined. Check that they really aren't. */ - undeftab = xmalloc (m.definition_length); + undeftab = XNEWVEC (unsigned char, m.definition_length); if ((size_t) read (fd, undeftab, m.definition_length) != m.definition_length) goto error; /* Collect identifiers from the current hash table. */ nl.n_defs = 0; nl.asize = 10; - nl.defs = xmalloc (nl.asize * sizeof (cpp_hashnode *)); + nl.defs = XNEWVEC (cpp_hashnode *, nl.asize); cpp_forall_identifiers (r, &collect_ht_nodes, &nl); qsort (nl.defs, nl.n_defs, sizeof (cpp_hashnode *), &comp_hashnodes); @@ -577,8 +577,7 @@ save_macros (cpp_reader *r, cpp_hashnode *h, void *data_p) if (data->count == data->array_size) { data->array_size *= 2; - data->defns = xrealloc (data->defns, (data->array_size - * sizeof (uchar *))); + data->defns = XRESIZEVEC (uchar *, data->defns, (data->array_size)); } switch (h->type) @@ -592,7 +591,8 @@ save_macros (cpp_reader *r, cpp_hashnode *h, void *data_p) const uchar * defn = cpp_macro_definition (r, h); size_t defnlen = ustrlen (defn); - data->defns[data->count] = xmemdup (defn, defnlen, defnlen + 2); + data->defns[data->count] = (uchar *) xmemdup (defn, defnlen, + defnlen + 2); data->defns[data->count][defnlen] = '\n'; } break; @@ -611,10 +611,10 @@ save_macros (cpp_reader *r, cpp_hashnode *h, void *data_p) void cpp_prepare_state (cpp_reader *r, struct save_macro_data **data) { - struct save_macro_data *d = xmalloc (sizeof (struct save_macro_data)); + struct save_macro_data *d = XNEW (struct save_macro_data); d->array_size = 512; - d->defns = xmalloc (d->array_size * sizeof (d->defns[0])); + d->defns = XNEWVEC (uchar *, d->array_size); d->count = 0; cpp_forall_identifiers (r, save_macros, d); d->saved_pragmas = _cpp_save_pragma_names (r); -- cgit v1.1