Ejemplo n.º 1
0
Archivo: dbpack.c Proyecto: braddr/cold
static Method *unpack_method(cBuf *buf, Long *buf_pos)
{
    Int     i, j, n;
    Method *method;
    Int     name;

    /* Read in the name.  If this is -1, it was a marker for a blank entry. */
    name = read_ident(buf, buf_pos);
    if (name == NOT_AN_IDENT)
	return NULL;

    method = EMALLOC(Method, 1);

    method->name = name;
    method->m_access = read_long(buf, buf_pos);
    method->m_flags = read_long(buf, buf_pos);
    method->native = read_long(buf, buf_pos);
    method->refs = 1;

    method->num_args = read_long(buf, buf_pos);
    if (method->num_args) {
	method->argnames = TMALLOC(Int, method->num_args);
	for (i = 0; i < method->num_args; i++) {
	    method->argnames[i] = read_long(buf, buf_pos);
        }
    }
    method->rest = read_long(buf, buf_pos);

    method->num_vars = read_long(buf, buf_pos);
    if (method->num_vars) {
	method->varnames = TMALLOC(Int, method->num_vars);
	for (i = 0; i < method->num_vars; i++) {
	    method->varnames[i] = read_long(buf, buf_pos);
        }
    }

    method->num_opcodes = read_long(buf, buf_pos);
    method->opcodes = TMALLOC(Long, method->num_opcodes);
    for (i = 0; i < method->num_opcodes; i++)
	method->opcodes[i] = read_long(buf, buf_pos);

    method->num_error_lists = read_long(buf, buf_pos);
    if (method->num_error_lists) {
	method->error_lists = TMALLOC(Error_list, method->num_error_lists);
	for (i = 0; i < method->num_error_lists; i++) {
	    n = read_long(buf, buf_pos);
	    method->error_lists[i].num_errors = n;
	    method->error_lists[i].error_ids = TMALLOC(Int, n);
	    for (j = 0; j < n; j++)
		method->error_lists[i].error_ids[j] = read_ident(buf, buf_pos);
	}
    }

    return method;
}
Ejemplo n.º 2
0
int
YMSHnewCard(GENcard **inCard, GENmodel *inModel)
{
    MESHcard *tmpCard, *newCard;
    GENnumModel *model = (GENnumModel *)inModel;

    newCard = TMALLOC(MESHcard, 1);
    if (!newCard) {
        *inCard = NULL;
        return(E_NOMEM);
    }
    newCard->MESHnextCard = NULL;
    *inCard = (GENcard *) newCard;

    tmpCard = model->GENyMeshes;
    if (!tmpCard) { /* First in list */
        model->GENyMeshes = newCard;
    } else {
	/* Go to end of list */
        while (tmpCard->MESHnextCard) tmpCard = tmpCard->MESHnextCard;
	/* And add new card */
	tmpCard->MESHnextCard = newCard;
    }
    return(OK);
}
tAsyncCall* System_Threading_Thread_Sleep(PTR pThis_, PTR pParams, PTR pReturnValue) {
	tAsyncCall *pAsync = TMALLOC(tAsyncCall);

	pAsync->sleepTime = ((I32*)pParams)[0];

	return pAsync;
}
Ejemplo n.º 4
0
static NODE
*NEW_node(void)
{
    NODE *n;

    n = TMALLOC(NODE, 1);
    n->mptr = NULL;
    n->gptr = NULL;
    n->cptr = NULL;
    n->rptr = NULL;
    n->tptr = NULL;
    n->cplptr = NULL;
    n->rlptr = NULL;
    n->ddptr = NULL;
    n->cvccsptr = NULL;
    n->vccsptr = NULL;
    n->CL = 0.0;
    n->V = n->dv = 0.0;
    n->gsum = n->cgsum = 0;
    n->is   = 0;
    n->tag  = 0;
    n->flag = 0;
    n->region = NULL;
    n->ofile = NULL;
    n->dvtag = 0;

    return(n);
}
Ejemplo n.º 5
0
Archivo: gens.c Proyecto: imr/ngspice
dgen *
dgen_init(CKTcircuit *ckt, wordlist *wl, int nomix, int flag, int model)
{
    dgen  *dg, *dg_save;

    NG_IGNORE(nomix);

    dg = TMALLOC(dgen, 1);
    dg->ckt = ckt;
    dg->instance = NULL;
    dg->model = NULL;
    dg->dev_type_no = -1;
    dg->dev_list = wl;
    dg->flags = 0;
    dg_save = dg; /* va: save, to avoid memory leak */

    if (model)
        dg->flags = (DGEN_ALL & ~ DGEN_INSTANCE) | DGEN_INIT;
    else
        dg->flags = DGEN_ALL | DGEN_INIT;

    if (wl)
        dg->flags |= flag;
    else
        dg->flags |= DGEN_DEFDEVS | flag;

    dgen_next(&dg);
    /* va: it might be too much tests, but safer is better... */
    if (dg != dg_save && dg == NULL && dg_save != NULL)
        tfree(dg_save);

    return dg;
}
Ejemplo n.º 6
0
sgen *
sgen_init(CKTcircuit *ckt, int is_dc)
{
	sgen	*sg;

	sg = TMALLOC(sgen, 1);
	sg->param = 99999;
	sg->is_instparam = 0;
	sg->dev = -1;
	sg->istate = 0;
	sg->ckt = ckt;
	sg->devlist = ckt->CKThead;
	sg->instance = sg->first_instance = sg->next_instance = NULL;
	sg->model = sg->next_model = NULL;
	sg->ptable = NULL;
	sg->is_dc = is_dc;
	sg->is_principle = 0;
	sg->is_q = 0;
	sg->is_zerook = 0;
	sg->value = 0.0;

	sgen_next(&sg);	/* get the ball rolling XXX check return val? */

	return sg;
}
Ejemplo n.º 7
0
GRAPH *
NewGraph(void)
{
    GRAPH *pgraph;
    LISTGRAPH *list;
    int BucketId = RunningId % NUMGBUCKETS;

    if ((list = TMALLOC(LISTGRAPH, 1)) == NULL) {
        internalerror("can't allocate a listgraph");
        return (NULL);
    }

    pgraph = &list->graph;
    SETGRAPH(pgraph, RunningId);

    if (!GBucket[BucketId].list) {
        GBucket[BucketId].list = list;
    } else {
        /* insert at front of current list */
        list->next = GBucket[BucketId].list;
        GBucket[BucketId].list = list;
    }

    RunningId++;

    return (pgraph);
}
Ejemplo n.º 8
0
static void EVTcreate_output_event(
    CKTcircuit  *ckt,           /* The circuit structure */
    int         node_index,     /* The node type port is on */
    int         output_index,   /* The output index for this port */
    void        **value_ptr)    /* The event created */
{
    int                 udn_index;
    Evt_Node_Info_t     **node_table;
    Evt_Output_Queue_t  *output_queue;
    Evt_Output_Event_t  *event;


    /* Check the output queue free list and use the structure */
    /* at the head of the list if non-null.  Otherwise, create a new one. */
    output_queue = &(ckt->evt->queue.output);
    if(output_queue->free[output_index]) {
        *value_ptr = output_queue->free[output_index]->value;
    }
    else {
        /* Create a new event */
        event = TMALLOC(Evt_Output_Event_t, 1);
        event->next = NULL;

        /* Initialize the value */
        node_table = ckt->evt->info.node_table;
        udn_index = node_table[node_index]->udn_index;
        g_evt_udn_info[udn_index]->create (&(event->value));

        /* Put the event onto the free list and return the value pointer */
        output_queue->free[output_index] = event;
        *value_ptr = event->value;
    }
}
Ejemplo n.º 9
0
static void
unused_rules(void)
{
    int i;
    action *p;

    rules_used = TMALLOC(Value_t, nrules);
    NO_SPACE(rules_used);

    for (i = 0; i < nrules; ++i)
	rules_used[i] = 0;

    for (i = 0; i < nstates; ++i)
    {
	for (p = parser[i]; p; p = p->next)
	{
	    if ((p->action_code == REDUCE) && MaySuppress(p))
		rules_used[p->number] = 1;
	}
    }

    nunused = 0;
    for (i = 3; i < nrules; ++i)
	if (!rules_used[i])
	    ++nunused;

    if (nunused)
    {
	if (nunused == 1)
	    fprintf(stderr, "%s: 1 rule never reduced\n", myname);
	else
	    fprintf(stderr, "%s: %d rules never reduced\n", myname, nunused);
    }
}
Ejemplo n.º 10
0
int INPmakeMod(char *token, int type, card * line)
{
   printf("aaaaa %s\n",token);
    register INPmodel **i;

   /* First cycle through model table and see if model name
      already exists in there.  If it does, just return. */
   for (i = &modtab; *i != NULL; i = &((*i)->INPnextModel)) {
      if (strcmp((*i)->INPmodName, token) == 0) {
         return (OK);
      }
   }

   /* Model name was not already in model table.  Therefore stick
      it in the model table. Then return.  */

#ifdef TRACE
   /* debug statement */
   printf("In INPmakeMod, about to insert new model name = %s . . .\n", token);
#endif

   *i = TMALLOC(INPmodel, 1);
   if (*i == NULL)
      return (E_NOMEM);

   (*i)->INPmodName = token;                 /* model name */
   (*i)->INPmodType = type;                  /* model type */
   (*i)->INPnextModel = NULL;   /* pointer to next model (end of list) */
   (*i)->INPmodLine = line;                  /* model line */
   (*i)->INPmodfast = NULL;
   return (OK);
}
Ejemplo n.º 11
0
// Returns a TypeDef for an array to the given element type
tMD_TypeDef* Type_GetArrayTypeDef(tMD_TypeDef *pElementType, tMD_TypeDef **ppClassTypeArgs, tMD_TypeDef **ppMethodTypeArgs) {
	tArrayTypeDefs *pIterArrays;

	if (pElementType == NULL) {
		return types[TYPE_SYSTEM_ARRAY_NO_TYPE];
	}
	
	pIterArrays = pArrays;
	while (pIterArrays != NULL) {
		if (pIterArrays->pElementType == pElementType) {
			return pIterArrays->pArrayType;
		}
		pIterArrays = pIterArrays->pNext;
	}

	// Must have this new array type in the linked-list of array types before it is initialised
	// (otherwise it can get stuck in an infinite loop)
	pIterArrays = TMALLOCFOREVER(tArrayTypeDefs);
	pIterArrays->pElementType = pElementType;
	pIterArrays->pNext = pArrays;
	pArrays = pIterArrays;
	pIterArrays->pArrayType = TMALLOC(tMD_TypeDef);

	CreateNewArrayType(pIterArrays->pArrayType, pElementType, ppClassTypeArgs, ppMethodTypeArgs);
	return pIterArrays->pArrayType;
}
Ejemplo n.º 12
0
Archivo: dbpack.c Proyecto: braddr/cold
Ident read_ident(cBuf *buf, Long *buf_pos)
{
    Int   len;
    Char *s;
    Ident id;

    /* Read the length of the identifier. */
    len = read_long(buf, buf_pos);

    /* If the length is -1, it's not really an identifier, but a -1 signalling
     * a blank variable or method. */
    if (len == NOT_AN_IDENT)
	return NOT_AN_IDENT;

    /* Otherwise, it's an identifier.  Read it into temporary storage. */
    s = TMALLOC(Char, len + 1);
    MEMCPY(s, &(buf->s[*buf_pos]), len);
    (*buf_pos) += len;
    s[len] = 0;

    /* Get the index for the identifier and free the temporary memory. */
    id = ident_get(s);
    tfree_chars(s);

    return id;
}
Ejemplo n.º 13
0
tFontFamily* CreateFontFamily_Name_(STRING name) {
    tFontFamily *pFontFamily = TMALLOC(tFontFamily);

    pFontFamily->familyName = malloc(strlen(name)+1);
    strcpy(pFontFamily->familyName, name);

    return pFontFamily;
}
Ejemplo n.º 14
0
static dictIterator *dictGetIterator(dict *ht) {
	dictIterator *iter = TMALLOC(sizeof(*iter));

    iter->ht = ht;
    iter->index = -1;
    iter->entry = NULL;
    iter->nextEntry = NULL;
    return iter;
}
Ejemplo n.º 15
0
void unpack_handled (cBuf *buf, Long *buf_pos, cData *d)
{
    HandledFrob *h=TMALLOC(HandledFrob, 1);

    h->cclass = read_long(buf, buf_pos);
    unpack_data (buf, buf_pos, &h->rep);
    h->handler = read_ident(buf, buf_pos);
    d->u.instance = (void*) h;
}
Ejemplo n.º 16
0
void dup_handled (cData *dest, cData *source)
{
    HandledFrob *s = HANDLED_FROB(source),
	        *d = TMALLOC(HandledFrob, 1);

    d->cclass = s->cclass;
    d->handler = ident_dup(s->handler);
    data_dup (&d->rep, &s->rep);
    dest->u.instance = d;
}
Ejemplo n.º 17
0
void cm_analog_alloc(
    int tag,            /* The user-specified tag for this block of memory */
    int bytes)          /* The number of bytes to allocate */
{
    MIFinstance *here;
    CKTcircuit  *ckt;

    Mif_State_t *state;

    int         doubles_needed;
    int         i;


    /* Get the address of the ckt and instance structs from g_mif_info */
    here = g_mif_info.instance;
    ckt  = g_mif_info.ckt;

    /* Scan states in instance struct and see if tag has already been used */
    for(i = 0; i < here->num_state; i++) {
        if(tag == here->state[i].tag) {
            g_mif_info.errmsg = "ERROR - cm_analog_alloc() - Tag already used in previous call\n";
            return;
        }
    }

    /* Compute number of doubles needed and allocate space in ckt->CKTstates[i] */
    doubles_needed = bytes / (int) sizeof(double) + 1;

    /* Allocate space in instance struct for this state descriptor */
    if(here->num_state == 0) {
        here->num_state = 1;
        here->state = TMALLOC(Mif_State_t, 1);
    }
    else {
        here->num_state++;
        here->state = TREALLOC(Mif_State_t, here->state, here->num_state);
    }

    /* Fill in the members of the state descriptor struct */
    state = &(here->state[here->num_state - 1]);
    state->tag = tag;
    state->index = ckt->CKTnumStates;
    state->doubles = doubles_needed;
    state->bytes = bytes;


    /* Add the states to the ckt->CKTstates vectors */
    ckt->CKTnumStates += doubles_needed;
    for(i=0;i<=ckt->CKTmaxOrder+1;i++) {
        if(ckt->CKTnumStates == doubles_needed)
            ckt->CKTstates[i] = TMALLOC(double, ckt->CKTnumStates);
        else
            ckt->CKTstates[i] = TREALLOC(double, ckt->CKTstates[i], ckt->CKTnumStates);
    }
tAsyncCall* System_Net_Sockets_Internal_Accept(PTR pThis_, PTR pParams, PTR pReturnValue) {
	U32 ret = Accept_Check(pThis_, pParams, pReturnValue, NULL);
	if (ret) {
		return NULL;
	} else {
		tAsyncCall *pAsync = TMALLOC(tAsyncCall);
		pAsync->sleepTime = -1;
		pAsync->checkFn = Accept_Check;
		pAsync->state = NULL;
		return pAsync;
	}
}
Ejemplo n.º 19
0
static void EVTcreate_state(
    CKTcircuit  *ckt,         /* The circuit structure */
    int         inst_index)   /* The instance to create state for */
{
    size_t              total_size;

    Evt_State_Data_t    *state_data;

    Evt_State_t         *new_state;
    Evt_State_t         *prev_state;

    /* Get variables for fast access */
    state_data = ckt->evt->data.state;

    /* Exit immediately if no states on this instance */
    if(state_data->desc[inst_index] == NULL)
        return;

    /* Get size of state block to be allocated */
    total_size = (size_t) state_data->total_size[inst_index];

    /* Allocate a new state for the instance */
    if(state_data->free[inst_index]) 
	{
        new_state = state_data->free[inst_index];
        state_data->free[inst_index] = new_state->next;
    }
    else 
	{
		
        new_state = TMALLOC(Evt_State_t, 1);
        new_state->block = tmalloc(total_size);

    }

    /* Splice the new state into the state data linked list */
    /* and update the tail pointer */
    prev_state = *(state_data->tail[inst_index]);
    prev_state->next = new_state;
    new_state->prev = prev_state;
    state_data->tail[inst_index] = &(prev_state->next);

    /* Copy the old state to the new state and set the step */
    memcpy(new_state->block, prev_state->block, total_size);
    new_state->step = g_mif_info.circuit.evt_step;

    /* Mark that the state data on the instance has been modified */
    if(! state_data->modified[inst_index]) {
        state_data->modified[inst_index] = MIF_TRUE;
        state_data->modified_index[(state_data->num_modified)++] = inst_index;
    }
}
Ejemplo n.º 20
0
tAsyncCall* System_Threading_Monitor_Internal_TryEnter(PTR pThis_, PTR pParams, PTR pReturnValue) {
	U32 ok = Internal_TryEntry_Check(pThis_, pParams, pReturnValue, NULL);
	tAsyncCall *pAsync;
	if (ok) {
		// Got lock already, so don't block thread
		return NULL;
	}
	pAsync = TMALLOC(tAsyncCall);
	pAsync->sleepTime = -1;
	pAsync->checkFn = Internal_TryEntry_Check;
	pAsync->state = NULL;
	return pAsync;
}
Ejemplo n.º 21
0
static void EVTadd_msg(
    CKTcircuit  *ckt,          /* The circuit structure */
    int         port_index,    /* The port to add message to */
    char        *msg_text)     /* The message text */
{

    Evt_Msg_Data_t      *msg_data;

    Evt_Msg_t           **msg_ptr;
    Evt_Msg_t           *msg;


    /* Get pointers for fast access */
    msg_data = ckt->evt->data.msg;
    msg_ptr = msg_data->tail[port_index];

    /* Set pointer to location at which to add, and update tail */
    if(*msg_ptr != NULL) {
        msg_ptr = &((*msg_ptr)->next);
        msg_data->tail[port_index] = msg_ptr;
    }

    /* Add a new entry in the list of messages for this port */
    if(msg_data->free[port_index]) {
        *msg_ptr = msg_data->free[port_index];
        msg_data->free[port_index] = msg_data->free[port_index]->next;
        if ((*msg_ptr)->text)
            tfree((*msg_ptr)->text);
    }
    else {
        *msg_ptr = TMALLOC(Evt_Msg_t, 1);
    }

    /* Fill in the values */
    msg = *msg_ptr;
    msg->next = NULL;
    if((ckt->CKTmode & MODEDCOP) == MODEDCOP)
        msg->op = MIF_TRUE;
    else
        msg->step = g_mif_info.circuit.evt_step;
    msg->text = MIFcopy(msg_text);

    /* Update the modified indexes */
    if(g_mif_info.circuit.anal_type == MIF_TRAN) {
        if(! msg_data->modified[port_index]) {
            msg_data->modified[port_index] = MIF_TRUE;
            msg_data->modified_index[(msg_data->num_modified)++] = port_index;
        }
    }

}
Ejemplo n.º 22
0
/* devdep initially contains name of output file */
int
GL_NewViewport(GRAPH *graph)
{
    hcopygraphid = graph->graphid;

    if ((plotfile = fopen((char*) graph->devdep, "w")) == NULL) {
        perror((char*) graph->devdep);
        graph->devdep = NULL;
        return (1);
    }

    if (graph->absolute.width) {
        /* hardcopying from the screen */

        screenflag = 1;

        /* scale to fit on 8 1/2 square */

    }

    /* reasonable values, used in gr_ for placement */
    graph->fontwidth = (int)(fontwidth * scale); /* was 12, p.w.h. */
    graph->fontheight = (int)(fontheight * scale); /* was 24, p.w.h. */

    graph->absolute.width = dispdev->width;
    graph->absolute.height = dispdev->height;
    /* Also done in gr_init, if called . . . */
    graph->viewportxoff = 16 * fontwidth;
    graph->viewportyoff = 8 * fontheight;

    xoff = XOFF;
    yoff = YOFF;

    /* start file off with a % */
    fprintf(plotfile, "IN;DF;PA;");
    fprintf(plotfile, "SI %f,%f;", tocm*jgmult*fontwidth*scale, tocm*jgmult*fontheight*scale);

#ifdef notdef
    if (!screenflag)
#endif

        graph->devdep = TMALLOC(GLdevdep, 1);
    DEVDEP(graph).lastlinestyle = -1;
    DEVDEP(graph).lastx = -1;
    DEVDEP(graph).lasty = -1;
    DEVDEP(graph).linecount = 0;
    graph->linestyle = -1;

    return 0;
}
Ejemplo n.º 23
0
int
CKTnames(CKTcircuit *ckt, int *numNames, IFuid **nameList)
{
    CKTnode *here;
    int i;
    *numNames = ckt->CKTmaxEqNum-1;
    *nameList = TMALLOC(IFuid, *numNames);
    if (*numNames && (*nameList) == NULL) return(E_NOMEM);
    i=0;
    for (here = ckt->CKTnodes->next; here; here = here->next)  {
        (*nameList) [i++] = here->name;
    }
    return(OK);
}
Ejemplo n.º 24
0
/* note: This Push and Pop has tricky semantics.
   Push(graph) will push the currentgraph onto the stack
   and set currentgraph to graph.
   Pop() simply sets currentgraph to the top of the stack and pops stack.
*/
void
PushGraphContext(GRAPH *graph)
{
    GCSTACK *gcstack = TMALLOC(GCSTACK, 1);

    if (!gcstacktop) {
        gcstacktop = gcstack;
    } else {
        gcstack->next = gcstacktop;
        gcstacktop = gcstack;
    }
    gcstacktop->pgraph = currentgraph;
    currentgraph = graph;
}
Ejemplo n.º 25
0
/* ARGSUSED */
int
CKTmkNode(CKTcircuit *ckt, CKTnode **node)
{
    CKTnode *mynode;

    NG_IGNORE(ckt);

    mynode = TMALLOC(CKTnode, 1);
    if(mynode == NULL) return(E_NOMEM);
    mynode->next = NULL;
    mynode->name = NULL;

    if(node) *node = mynode;
    return(OK);
}
Ejemplo n.º 26
0
void verbose (void)
{
    int i;

    if (!vflag)
        return;

    null_rules = TMALLOC (Value_t, nrules);
    NO_SPACE (null_rules);

    fprintf (verbose_file, "\f\n");
    for (i = 0; i < nstates; i++)
        print_state (i);
    FREE (null_rules);

    if (nunused)
        log_unused ();
    if (SRtotal || RRtotal)
        log_conflicts ();

    fprintf (verbose_file, "\n\n%d terminals, %d nonterminals\n", ntokens,
             nvars);
    fprintf (verbose_file, "%d grammar rules, %d states\n", nrules - 2,
             nstates);
#if defined(YYBTYACC)
    { /* print out the grammar symbol # and parser internal symbol # for each
     symbol as an aide to writing the implementation for YYDESTRUCT_CALL()
     and YYSTYPE_TOSTRING() */
        int maxtok = 0;

        fputs ("\ngrammar parser grammar\n", verbose_file);
        fputs ("symbol# value# symbol\n", verbose_file);
        for (i = 0; i < ntokens; ++i)
        {
            fprintf (verbose_file, " %5d  %5d  %s\n", i, symbol_value[i],
                     symbol_name[i]);
            if (symbol_value[i] > maxtok)
                maxtok = symbol_value[i];
        }
        for (i = ntokens; i < nsyms; ++i)
            fprintf (verbose_file, " %5d  %5d  %s\n", i,
                     (maxtok + 1) + symbol_value[i] + 1, symbol_name[i]);
    }
#endif
}
Ejemplo n.º 27
0
/* Add an element to the target hash table */
static int dictAdd(dict *ht, void *key, void *val) {
    int index;
    dictEntry *entry;

    /* Get the index of the NEW element, or -1 if
     * the element already exists. */
    if ((index = _dictKeyIndex(ht, key)) == -1)
        return DICT_ERR;

    /* Allocates the memory and stores key */
	entry = TMALLOC(sizeof(*entry));
    entry->next = ht->table[index];
    ht->table[index] = entry;

    /* Set the hash entry fields. */
    dictSetHashKey(ht, entry, key);
    dictSetHashVal(ht, entry, val);
    ht->used++;
    return DICT_OK;
}
Ejemplo n.º 28
0
int
OPTNnewCard(GENcard **inCard, GENmodel *inModel)
{
    OPTNcard *tmpCard, *newCard;
    GENnumModel *model = (GENnumModel *)inModel;

    tmpCard = model->GENoptions;
    if (!tmpCard) { /* First in list */
        newCard = TMALLOC(OPTNcard, 1);
        if (!newCard) {
            *inCard = NULL;
            return(E_NOMEM);
        }
        newCard->OPTNnextCard = NULL;
        *inCard = (GENcard *) newCard;
        model->GENoptions = newCard;
    } else { /* Only one card of this type allowed */
        *inCard = (GENcard *) tmpCard;
    }
    return(OK);
}
Ejemplo n.º 29
0
Archivo: plotit.c Proyecto: imr/ngspice
static void
compress(struct dvec *d, double *xcomp, double *xind)
{
    int cfac, ihi, ilo, newlen, i;

    if (xind) {
        ilo = (int) xind[0];
        ihi = (int) xind[1];
        if ((ihi >= ilo) && (ilo > 0) && (ilo < d->v_length) &&
            (ihi > 1) && (ihi <= d->v_length)) {
            newlen = ihi - ilo;
            if (isreal(d)) {
                double *dd = TMALLOC(double, newlen);
                memcpy(dd, d->v_realdata + ilo, (size_t) newlen * sizeof(double));
                dvec_realloc(d, newlen, dd);
            } else {
                ngcomplex_t *cc = TMALLOC(ngcomplex_t, newlen);
                memcpy(cc, d->v_compdata + ilo, (size_t) newlen * sizeof(ngcomplex_t));
                dvec_realloc(d, newlen, cc);
            }
        }
Ejemplo n.º 30
0
static NDnamePt
insert_ND(char *name, NDnamePt *ndn)
{
    int       cmp;
    NDnamePt  p;

    if (*ndn == NULL) {
        p = *ndn = TMALLOC(NDname, 1);
        p->nd = NULL;
        p->right = p->left = NULL;
        strcpy(p->id, name);
        return(p);
    }
    cmp = strcmp((*ndn)->id, name);
    if (cmp == 0)
        return(*ndn);
    else {
        if (cmp < 0)
            return(insert_ND(name, &((*ndn)->left)));
        else
            return(insert_ND(name, &((*ndn)->right)));
    }
}