void *x_alloc(UINT32 size) { struct content_t *node; alloc_enter_mutex(); node = alloc_content(&alloc_obj.free_list, size); alloc_leave_mutex(); if (node == NULL) { alloc_obj.status = STATUS_UNAVAILABLE; return NULL; } return (void*)((UINT32)node+sizeof(struct content_t)); }
int mpl_read_model(MPL *mpl, char *file, int skip_data) { if (mpl->phase != 0) xfault("mpl_read_model: invalid call sequence\n"); if (file == NULL) xfault("mpl_read_model: no input filename specified\n"); /* set up error handler */ if (setjmp(mpl->jump)) goto done; /* translate model section */ mpl->phase = 1; xprintf("Reading model section from %s...\n", file); open_input(mpl, file); model_section(mpl); if (mpl->model == NULL) error(mpl, "empty model section not allowed"); /* save name of the input text file containing model section for error diagnostics during the generation phase */ mpl->mod_file = xcalloc(strlen(file)+1, sizeof(char)); strcpy(mpl->mod_file, mpl->in_file); /* allocate content arrays for all model objects */ alloc_content(mpl); /* optional data section may begin with the keyword 'data' */ if (is_keyword(mpl, "data")) { if (skip_data) { warning(mpl, "data section ignored"); goto skip; } mpl->flag_d = 1; get_token(mpl /* data */); if (mpl->token != T_SEMICOLON) error(mpl, "semicolon missing where expected"); get_token(mpl /* ; */); /* translate data section */ mpl->phase = 2; xprintf("Reading data section from %s...\n", file); data_section(mpl); } /* process end statement */ end_statement(mpl); skip: xprintf("%d line%s were read\n", mpl->line, mpl->line == 1 ? "" : "s"); close_input(mpl); done: /* return to the calling program */ return mpl->phase; }
void *x_alloc(UINT32 size) { struct content_t *node; alloc_enter_mutex(); node = alloc_content(&alloc_obj.free_list, size); alloc_leave_mutex(); #if (X_ALLOC_DEBUG_LEVEL > 0) print_freemem_size(); #endif if (node == NULL) { alloc_obj.status = STATUS_UNAVAILABLE; return NULL; } return (void*)((UINT32)node+sizeof(struct content_t)); }