int main_name (int argc, const char ** argv) { init_exit_scheme (); scheme_program_name = (argv[0]); initial_C_stack_pointer = ((void *) (&argc)); #ifdef __WIN32__ NT_initialize_win32_system_utilities (); #endif #ifdef PREALLOCATE_HEAP_MEMORY PREALLOCATE_HEAP_MEMORY (); #endif #ifdef __OS2__ OS2_initialize_early (); #endif obstack_init (&scratch_obstack); obstack_init (&ffi_obstack); dstack_initialize (); transaction_initialize (); reload_saved_string = 0; reload_saved_string_length = 0; read_command_line_options (argc, argv); setup_memory ((BLOCKS_TO_BYTES (option_heap_size)), (BLOCKS_TO_BYTES (option_stack_size)), (BLOCKS_TO_BYTES (option_constant_size))); initialize_primitives (); compiler_initialize (option_fasl_file != 0); OS_initialize (); start_scheme (); termination_init_error (); return (0); }
void conflicts_solve (void) { state_number i; /* List of lookahead tokens on which we explicitly raise a syntax error. */ symbol **errors = xnmalloc (ntokens + 1, sizeof *errors); conflicts = xcalloc (nstates, sizeof *conflicts); shift_set = bitset_create (ntokens, BITSET_FIXED); lookahead_set = bitset_create (ntokens, BITSET_FIXED); obstack_init (&solved_conflicts_obstack); obstack_init (&solved_conflicts_xml_obstack); for (i = 0; i < nstates; i++) { set_conflicts (states[i], errors); /* For uniformity of the code, make sure all the states have a valid `errs' member. */ if (!states[i]->errs) states[i]->errs = errs_new (0, 0); } free (errors); }
void output_red (state const *s, reductions const *reds, FILE *fout) { bitset no_reduce_set; int j; int source = s->number; /* Two obstacks are needed: one for the enabled reductions, and one for the disabled reductions, because in the end we want two separate edges, even though in most cases only one will actually be printed. */ struct obstack dout; struct obstack eout; no_reduce_bitset_init (s, &no_reduce_set); obstack_init (&dout); obstack_init (&eout); for (j = 0; j < reds->num; ++j) { bool defaulted = false; bool firstd = true; bool firste = true; rule_number ruleno = reds->rules[j]->number; rule *default_reduction = NULL; if (yydefact[s->number] != 0) default_reduction = &rules[yydefact[s->number] - 1]; /* Build the lookahead tokens lists, one for enabled transitions and one for disabled transistions. */ if (default_reduction && default_reduction == reds->rules[j]) defaulted = true; if (reds->lookahead_tokens) { int i; for (i = 0; i < ntokens; i++) if (bitset_test (reds->lookahead_tokens[j], i)) { if (bitset_test (no_reduce_set, i)) firstd = print_token (&dout, firstd, symbols[i]->tag); else { if (! defaulted) firste = print_token (&eout, firste, symbols[i]->tag); bitset_set (no_reduce_set, i); } } } /* Do the actual output. */ conclude_red (&dout, source, ruleno, false, firstd, fout); conclude_red (&eout, source, ruleno, true, firste && !defaulted, fout); } obstack_free (&dout, 0); obstack_free (&eout, 0); bitset_free (no_reduce_set); }
void readtokens0_init (struct Tokens *t) { t->n_tok = 0; t->tok = NULL; t->tok_len = NULL; obstack_init (&t->o_data); obstack_init (&t->o_tok); obstack_init (&t->o_tok_len); }
bool pop_wrapup (void) { next = NULL; obstack_free (current_input, NULL); free (current_input); if (wsp == NULL) { /* End of the program. Free all memory even though we are about to exit, since it makes leak detection easier. */ obstack_free (&token_stack, NULL); obstack_free (&file_names, NULL); obstack_free (wrapup_stack, NULL); free (wrapup_stack); #ifdef ENABLE_CHANGEWORD regfree (&word_regexp); #endif /* ENABLE_CHANGEWORD */ return false; } current_input = wrapup_stack; wrapup_stack = (struct obstack *) xmalloc (sizeof (struct obstack)); obstack_init (wrapup_stack); isp = wsp; wsp = NULL; input_change = true; return true; }
void check_obstack_vprintf (const char *want, const char *fmt, va_list ap) { #if HAVE_OBSTACK_VPRINTF struct obstack ob; int got_len, want_len, ob_len; char *got; want_len = strlen (want); obstack_init (&ob); got_len = gmp_obstack_vprintf (&ob, fmt, ap); got = obstack_base (&ob); ob_len = obstack_object_size (&ob); if (got_len != want_len || ob_len != want_len || memcmp (got, want, want_len) != 0) { printf ("gmp_obstack_vprintf wrong\n"); printf (" fmt |%s|\n", fmt); printf (" got |%s|\n", got); printf (" want |%s|\n", want); printf (" got_len %d\n", got_len); printf (" ob_len %d\n", ob_len); printf (" want_len %d\n", want_len); abort (); } obstack_free (&ob, NULL); #endif }
/** * Ensure the obstack is properly initialized. */ static void ensureobstackinit(void) { if (!tarobs_init) { obstack_init(&tar_obs); tarobs_init = true; } }
void init_mode(void) { obstack_init(&modes); mode_list = NEW_ARR_F(ir_mode*, 0); /* initialize predefined modes */ mode_BB = new_non_data_mode("BB"); mode_X = new_non_data_mode("X"); mode_M = new_non_data_mode("M"); mode_T = new_non_data_mode("T"); mode_ANY = new_non_data_mode("ANY"); mode_BAD = new_non_data_mode("BAD"); mode_b = alloc_mode("b", irms_internal_boolean, irma_none, 1, 0, 0); mode_b = register_mode(mode_b); mode_F = new_float_mode("F", irma_ieee754, 8, 23, ir_overflow_min_max); mode_D = new_float_mode("D", irma_ieee754, 11, 52, ir_overflow_min_max); mode_Bs = new_int_mode("Bs", irma_twos_complement, 8, 1, 32); mode_Bu = new_int_mode("Bu", irma_twos_complement, 8, 0, 32); mode_Hs = new_int_mode("Hs", irma_twos_complement, 16, 1, 32); mode_Hu = new_int_mode("Hu", irma_twos_complement, 16, 0, 32); mode_Is = new_int_mode("Is", irma_twos_complement, 32, 1, 32); mode_Iu = new_int_mode("Iu", irma_twos_complement, 32, 0, 32); mode_Ls = new_int_mode("Ls", irma_twos_complement, 64, 1, 64); mode_Lu = new_int_mode("Lu", irma_twos_complement, 64, 0, 64); mode_P = new_reference_mode("P", irma_twos_complement, 32, 32); }
void expand_input (void) { token_type t; token_data td; int line; obstack_init (&argc_stack); obstack_init (&argv_stack); while ((t = next_token (&td, &line)) != TOKEN_EOF) expand_token ((struct obstack *) NULL, t, &td, line); obstack_free (&argc_stack, NULL); obstack_free (&argv_stack, NULL); }
Hash_table * hash_initialize (unsigned candidate, const Hash_tuning *tuning, Hash_hasher hasher, Hash_comparator comparator, Hash_data_freer data_freer) { Hash_table *table; struct hash_entry *bucket; if (hasher == NULL || comparator == NULL) return NULL; table = (Hash_table *) malloc (sizeof (Hash_table)); if (table == NULL) return NULL; if (!tuning) tuning = &default_tuning; table->tuning = tuning; if (!check_tuning (table)) { /* Fail if the tuning options are invalid. This is the only occasion when the user gets some feedback about it. Once the table is created, if the user provides invalid tuning options, we silently revert to using the defaults, and ignore further request to change the tuning options. */ free (table); return NULL; } table->n_buckets = next_prime (tuning->is_n_buckets ? candidate : (unsigned) (candidate / tuning->growth_threshold)); table->bucket = (struct hash_entry *) malloc (table->n_buckets * sizeof (struct hash_entry)); if (table->bucket == NULL) { free (table); return NULL; } table->bucket_limit = table->bucket + table->n_buckets; for (bucket = table->bucket; bucket < table->bucket_limit; bucket++) { bucket->data = NULL; bucket->next = NULL; } table->n_buckets_used = 0; table->n_entries = 0; table->hasher = hasher; table->comparator = comparator; table->data_freer = data_freer; table->free_entry_list = NULL; #if USE_OBSTACK obstack_init (&table->entry_stack); #endif return table; }
int main( int argc, char **argv ) { char *s = "Hello world"; char *s2 = "**Helsssssssssssssssssssssssssssslo world**"; char *p, *p2; obstack_init( &os ); p = (char*)obstack_copy0( &os, s, strlen(s) ); p2 = (char*)obstack_copy0( &os, s2, strlen(s2) ); //printf("%s - %s %08lX %08lX\n", p, p2, p, p2 ); obstack_free( &os, p ); p = (char*)obstack_copy0( &os, s, strlen(s) ); p = (char*)obstack_copy0( &os, s, strlen(s) ); p2 = (char*)obstack_copy0( &os, s2, strlen(s2) ); //printf("%s - %s %08lX %08lX\n", p, p2, p, p2 ); obstack_grow( &os, s, strlen(s) ); obstack_grow( &os, s, strlen(s) ); obstack_grow( &os, s, strlen(s) ); obstack_grow( &os, s, strlen(s) ); obstack_grow( &os, s, strlen(s) ); obstack_grow( &os, s, strlen(s) ); obstack_grow0( &os, s, strlen(s) ); p = obstack_finish( &os ); obstack_grow0( &os, s, strlen(s) ); p = obstack_finish( &os ); printf("XXXXXX %s XXXXXX\n", p ); obstack_free( &os, NULL ); return 0; }
static void acls_one_line (const char *prefix, char delim, const char *aclstring, size_t len) { /* support both long and short text representation of posix acls */ struct obstack stk; int pref_len = strlen (prefix); const char *oldstring = aclstring; int pos = 0; if (!aclstring || !len) return; obstack_init (&stk); while (pos <= len) { int move = strcspn (aclstring, ",\n"); if (!move) break; if (oldstring != aclstring) obstack_1grow (&stk, delim); obstack_grow (&stk, prefix, pref_len); obstack_grow (&stk, aclstring, move); aclstring += move + 1; } obstack_1grow (&stk, '\0'); fprintf (stdlis, "%s", (char *) obstack_finish (&stk)); obstack_free (&stk, NULL); }
hidrd_ttbl * hidrd_ttbl_new(void) { hidrd_ttbl *tbl; hidrd_ttbl_row *row; hidrd_ttbl_cell *cell; tbl = malloc(sizeof(*tbl)); if (tbl == NULL) return NULL; obstack_init(&tbl->obstack); row = obstack_alloc(&tbl->obstack, sizeof(*row)); row->skip = 0; row->next = NULL; cell = obstack_alloc(&tbl->obstack, sizeof(*cell)); cell->skip = 0; cell->next = NULL; cell->text = NULL; row->cell = cell; tbl->row = row; return tbl; }
void init_driver(void) { obstack_init(&file_obst); colorterm = detect_color_terminal(); diagnostic_enable_color(colorterm); }
static void _PTGInit() { if (_PTGFirstObj) return; obstack_init(&_PTGObstack); _PTGFirstObj = obstack_alloc(&_PTGObstack, 0); }
struct check_instance * create_instance(struct check_instance *cptr, grad_nas_t *nas, struct radutmp *up) { RADCK_TYPE *radck_type; if ((radck_type = find_radck_type(nas->nastype)) == NULL) { grad_log(GRAD_LOG_ERR, _("unknown NAS type: %s (nas %s)"), nas->nastype, nas->shortname); return NULL; } cptr->name = up->orig_login[0] ? up->orig_login : up->login; cptr->port = up->nas_port; cptr->sid = up->session_id; cptr->framed_ip = ntohl(up->framed_address); cptr->nas_ip = ntohl(up->nas_address); cptr->result = -1; cptr->timeout = 0; cptr->nasname = nas->shortname ? nas->shortname : nas->longname; cptr->method = radck_type->method; cptr->args = grad_envar_merge_lists((grad_envar_t*) nas->args, radck_type->args); cptr->func = slookup(cptr, "function", NULL); obstack_init(&cptr->stack); return cptr; }
void compute_cdep(ir_graph *irg) { free_cdep(irg); cdep_data = XMALLOC(cdep_info); obstack_init(&cdep_data->obst); cdep_data->cdep_map = pmap_create(); assure_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_POSTDOMINANCE); /* we must temporary change the post dominator relation: the ipdom of the startblock is the end block. Firm does NOT add the phantom edge from Start to End. */ ir_node *const start_block = get_irg_start_block(irg); ir_node *const end_block = get_irg_end_block(irg); ir_node *const rem = get_Block_ipostdom(start_block); set_Block_ipostdom(start_block, end_block); irg_block_walk_graph(irg, cdep_pre, NULL, NULL); (void) cdep_edge_hook; /* restore the post dominator relation */ set_Block_ipostdom(start_block, rem); }
void append_incremental_renames (struct directory *dir) { struct obstack stk; size_t size; struct directory *dp; const char *dump; if (dirhead == NULL) return; obstack_init (&stk); dump = directory_contents (dir); if (dump) { size = dumpdir_size (dump) - 1; obstack_grow (&stk, dump, size); } else size = 0; for (dp = dirhead; dp; dp = dp->next) store_rename (dp, &stk); if (obstack_object_size (&stk) != size) { obstack_1grow (&stk, 0); dumpdir_free (dir->dump); dir->dump = dumpdir_create (obstack_finish (&stk)); } obstack_free (&stk, NULL); }
void init_types(unsigned machine_size) { obstack_init(&type_obst); atomic_type_properties_t *props = atomic_type_properties; /* atempt to set some sane defaults based on machine size */ unsigned int_size = machine_size < 32 ? 2 : 4; unsigned long_size = machine_size < 64 ? 4 : 8; props[ATOMIC_TYPE_INT].size = int_size; props[ATOMIC_TYPE_INT].alignment = int_size; props[ATOMIC_TYPE_UINT].size = int_size; props[ATOMIC_TYPE_UINT].alignment = int_size; props[ATOMIC_TYPE_LONG].size = long_size; props[ATOMIC_TYPE_LONG].alignment = long_size; props[ATOMIC_TYPE_ULONG].size = long_size; props[ATOMIC_TYPE_ULONG].alignment = long_size; pointer_properties.size = long_size; pointer_properties.alignment = long_size; pointer_properties.struct_alignment = long_size; props[ATOMIC_TYPE_LONG_DOUBLE] = props[ATOMIC_TYPE_DOUBLE]; props[ATOMIC_TYPE_WCHAR_T] = props[ATOMIC_TYPE_INT]; /* set struct alignments to the same value as alignment */ for (size_t i = 0; i != ARRAY_SIZE(atomic_type_properties); ++i) { props[i].struct_alignment = props[i].alignment; } }
static LONGEST windows_core_xfer_shared_libraries (struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, LONGEST len) { struct obstack obstack; const char *buf; LONGEST len_avail; struct cpms_data data = { gdbarch, &obstack, 0 }; obstack_init (&obstack); obstack_grow_str (&obstack, "<library-list>\n"); bfd_map_over_sections (core_bfd, core_process_module_section, &data); obstack_grow_str0 (&obstack, "</library-list>\n"); buf = obstack_finish (&obstack); len_avail = strlen (buf); if (offset >= len_avail) return 0; if (len > len_avail - offset) len = len_avail - offset; memcpy (readbuf, buf + offset, len); obstack_free (&obstack, NULL); return len; }
void init_types(unsigned int_size, unsigned long_size, unsigned pointer_size) { obstack_init(&type_obst); atomic_type_properties_t *props = atomic_type_properties; props[ATOMIC_TYPE_INT].size = int_size; props[ATOMIC_TYPE_INT].alignment = int_size; props[ATOMIC_TYPE_UINT].size = int_size; props[ATOMIC_TYPE_UINT].alignment = int_size; props[ATOMIC_TYPE_LONG].size = long_size; props[ATOMIC_TYPE_LONG].alignment = long_size; props[ATOMIC_TYPE_ULONG].size = long_size; props[ATOMIC_TYPE_ULONG].alignment = long_size; pointer_properties.size = pointer_size; pointer_properties.alignment = pointer_size; props[ATOMIC_TYPE_LONG_DOUBLE] = props[ATOMIC_TYPE_DOUBLE]; props[ATOMIC_TYPE_WCHAR_T] = props[ATOMIC_TYPE_INT]; /* set struct alignments to the same value as alignment */ for (size_t i = 0; i != ARRAY_SIZE(atomic_type_properties); ++i) { props[i].struct_alignment = props[i].alignment; } pointer_properties.struct_alignment = pointer_size; }
Hash_table * hash_initialize (size_t candidate, const Hash_tuning *tuning, Hash_hasher hasher, Hash_comparator comparator, Hash_data_freer data_freer) { Hash_table *table; if (hasher == NULL || comparator == NULL) return NULL; table = malloc (sizeof *table); if (table == NULL) return NULL; if (!tuning) tuning = &default_tuning; table->tuning = tuning; if (!check_tuning (table)) { /* Fail if the tuning options are invalid. This is the only occasion when the user gets some feedback about it. Once the table is created, if the user provides invalid tuning options, we silently revert to using the defaults, and ignore further request to change the tuning options. */ goto fail; } if (!tuning->is_n_buckets) { float new_candidate = candidate / tuning->growth_threshold; if (SIZE_MAX <= new_candidate) goto fail; candidate = new_candidate; } if (xalloc_oversized (candidate, sizeof *table->bucket)) goto fail; table->n_buckets = next_prime (candidate); if (xalloc_oversized (table->n_buckets, sizeof *table->bucket)) goto fail; table->bucket = calloc (table->n_buckets, sizeof *table->bucket); table->bucket_limit = table->bucket + table->n_buckets; table->n_buckets_used = 0; table->n_entries = 0; table->hasher = hasher; table->comparator = comparator; table->data_freer = data_freer; table->free_entry_list = NULL; #if USE_OBSTACK obstack_init (&table->entry_stack); #endif return table; fail: free (table); return NULL; }
/* Allocate and initialize a keyword set object, returning an opaque pointer to it. Return NULL if memory is not available. */ kwset_t kwsalloc (char const *trans) { struct kwset *kwset; kwset = (struct kwset *) malloc(sizeof (struct kwset)); if (!kwset) return 0; obstack_init(&kwset->obstack); kwset->words = 0; kwset->trie = (struct trie *) obstack_alloc(&kwset->obstack, sizeof (struct trie)); if (!kwset->trie) { kwsfree((kwset_t) kwset); return 0; } kwset->trie->accepting = 0; kwset->trie->links = 0; kwset->trie->parent = 0; kwset->trie->next = 0; kwset->trie->fail = 0; kwset->trie->depth = 0; kwset->trie->shift = 0; kwset->mind = INT_MAX; kwset->maxd = -1; kwset->target = 0; kwset->trans = trans; return (kwset_t) kwset; }
/* Read incremental snapshot format 2 */ static void read_incr_db_2 (void) { struct obstack stk; char offbuf[INT_BUFSIZE_BOUND (off_t)]; obstack_init (&stk); read_timespec (listed_incremental_stream, &newer_mtime_option); for (;;) { intmax_t i; struct timespec mtime; dev_t dev; ino_t ino; bool nfs; char *name; char *content; size_t s; if (! read_num (listed_incremental_stream, "nfs", 0, 1, &i)) return; /* Normal return */ nfs = i; read_timespec (listed_incremental_stream, &mtime); if (! read_num (listed_incremental_stream, "dev", TYPE_MINIMUM (dev_t), TYPE_MAXIMUM (dev_t), &i)) break; dev = i; if (! read_num (listed_incremental_stream, "ino", TYPE_MINIMUM (ino_t), TYPE_MAXIMUM (ino_t), &i)) break; ino = i; if (read_obstack (listed_incremental_stream, &stk, &s)) break; name = obstack_finish (&stk); while (read_obstack (listed_incremental_stream, &stk, &s) == 0 && s > 1) ; if (getc (listed_incremental_stream) != 0) FATAL_ERROR ((0, 0, _("%s: byte %s: %s"), quotearg_colon (listed_incremental_option), offtostr (ftello (listed_incremental_stream), offbuf), _("Missing record terminator"))); content = obstack_finish (&stk); note_directory (name, mtime, dev, ino, nfs, false, content); obstack_free (&stk, content); } FATAL_ERROR ((0, 0, "%s: %s", quotearg_colon (listed_incremental_option), _("Unexpected EOF in snapshot file"))); }
void ArrayPtrNew(ArrayPtr *arr) { arr->obstackPtr = (struct obstack *) malloc (sizeof (struct obstack)); obstack_init (arr->obstackPtr); obstack_alloc_failed_handler =&ArrayPtrAllocFailed; obstack_alignment_mask(arr->obstackPtr)=0; arr->totalNum=0; }
void runSuccess() { struct obstack o; obstack_init(&o); if (obstack_room(&o) >= sizeof(char)) { obstack_1grow_fast(&o, anyint()); } }
void init_temp_files(void) { obstack_init(&file_obst); tempsubdir = NULL; temp_files = NEW_ARR_F(char*, 0); atexit(exit_temp_files); }
//or char * string_copy_obs (char *in) { struct obstack os; obstack_init ( &os); char * out; int len = strlen (in) + 1; out = (char *) obstack_copy0 (&os, in, len); return out; }
void parse_language_map (char const *file_name) { if (obstack_init (&lang_args_obstack) == 0) error (EXIT_FAILURE, 0, _("can't allocate language args obstack: memory exhausted")); if (file_name == 0) file_name = LANGUAGE_MAP_FILE; parse_language_map_file (file_name, &lang_args_list); }
static void xheader_init (struct xheader *xhdr) { if (!xhdr->stk) { xhdr->stk = xmalloc (sizeof *xhdr->stk); obstack_init (xhdr->stk); } }