cast malloc... return values

This commit is contained in:
rlar 2010-07-09 16:53:34 +00:00
parent eb6e3e9827
commit d7e2e7f7f0
30 changed files with 171 additions and 139 deletions

View File

@ -1,3 +1,35 @@
2010-07-09 Robert Larice
* src/xspice/cm/cm.c ,
* src/xspice/cm/cmevt.c ,
* src/xspice/cmpp/pp_lst.c ,
* src/xspice/cmpp/writ_ifs.c ,
* src/xspice/enh/enhtrans.c ,
* src/xspice/evt/evtdump.c ,
* src/xspice/evt/evtinit.c ,
* src/xspice/evt/evtiter.c ,
* src/xspice/evt/evtload.c ,
* src/xspice/evt/evtnode_copy.c ,
* src/xspice/evt/evtop.c ,
* src/xspice/evt/evtplot.c ,
* src/xspice/evt/evtqueue.c ,
* src/xspice/evt/evtsetup.c ,
* src/xspice/evt/evttermi.c ,
* src/xspice/icm/digital/d_source/cfunc.mod ,
* src/xspice/icm/digital/d_state/cfunc.mod ,
* src/xspice/icm/spice2poly/icm_spice2poly/cfunc.mod ,
* src/xspice/icm/xtraevt/int/udnfunc.c ,
* src/xspice/icm/xtraevt/real/udnfunc.c ,
* src/xspice/ipc/ipctiein.c ,
* src/xspice/mif/mif_inp2.c ,
* src/xspice/mif/mifask.c ,
* src/xspice/mif/mifgetmod.c ,
* src/xspice/mif/mifgetvalue.c ,
* src/xspice/mif/mifmask.c ,
* src/xspice/mif/mifmpara.c ,
* src/xspice/mif/mifsetup.c ,
* src/xspice/mif/mifutil.c :
add and fix casts to the return values of malloc() function calls
2010-07-08 Robert Larice
* src/xspice/ipc/ipc.c ,
* src/xspice/mif/mif_inp2.c ,

View File

@ -107,11 +107,11 @@ void cm_analog_alloc(
/* Allocate space in instance struct for this state descriptor */
if(here->num_state == 0) {
here->num_state = 1;
here->state = (void *) MALLOC(sizeof(Mif_State_t));
here->state = (Mif_State_t *) MALLOC(sizeof(Mif_State_t));
}
else {
here->num_state++;
here->state = (void *) REALLOC(here->state,
here->state = (Mif_State_t *) REALLOC(here->state,
here->num_state * sizeof(Mif_State_t));
}
@ -279,11 +279,11 @@ int cm_analog_integrate(
if(! got_index) {
if(here->num_intgr == 0) {
here->num_intgr = 1;
here->intgr = (void *) MALLOC(sizeof(Mif_Intgr_t));
here->intgr = (Mif_Intgr_t *) MALLOC(sizeof(Mif_Intgr_t));
}
else {
here->num_intgr++;
here->intgr = (void *) REALLOC(here->intgr,
here->intgr = (Mif_Intgr_t *) REALLOC(here->intgr,
here->num_intgr * sizeof(Mif_Intgr_t));
}
intgr = &(here->intgr[here->num_intgr - 1]);
@ -361,11 +361,11 @@ int cm_analog_converge(
/* Allocate space in instance struct for this conv descriptor */
if(here->num_conv == 0) {
here->num_conv = 1;
here->conv = (void *) MALLOC(sizeof(Mif_Conv_t));
here->conv = (Mif_Conv_t *) MALLOC(sizeof(Mif_Conv_t));
}
else {
here->num_conv++;
here->conv = (void *) REALLOC(here->conv,
here->conv = (Mif_Conv_t *) REALLOC(here->conv,
here->num_conv * sizeof(Mif_Conv_t));
}

View File

@ -117,7 +117,7 @@ void cm_event_alloc(
/* Create a new state description structure at end of list */
/* and fill in the data and update the total size */
*desc_ptr = (void *) MALLOC(sizeof(Evt_State_Desc_t));
*desc_ptr = (Evt_State_Desc_t *) MALLOC(sizeof(Evt_State_Desc_t));
desc = *desc_ptr;
desc->tag = tag;
desc->size = bytes;
@ -127,7 +127,7 @@ void cm_event_alloc(
/* Create a new state structure if list starting at head is null */
state = state_data->head[inst_index];
if(state == NULL) {
state = (void *) MALLOC(sizeof(Evt_State_t));
state = (Evt_State_t *) MALLOC(sizeof(Evt_State_t));
state_data->head[inst_index] = state;
}

View File

@ -296,9 +296,9 @@ static Status_t read_modpath(
/* Allocate and initialize a new model info structure */
if(n == 0)
model = (void *) malloc(sizeof(Model_Info_t));
model = (Model_Info_t *) malloc(sizeof(Model_Info_t));
else
model = (void *) realloc(model, (n + 1) * sizeof(Model_Info_t));
model = (Model_Info_t *) realloc(model, (n + 1) * sizeof(Model_Info_t));
model[n].path_name = NULL;
model[n].spice_name = NULL;
model[n].cfunc_name = NULL;
@ -306,7 +306,7 @@ static Status_t read_modpath(
model[n].cfunc_unique = TRUE;
/* Put pathname into info structure */
model[n].path_name = malloc(len+1);
model[n].path_name = (char *) malloc(len+1);
strcpy(model[n].path_name, path);
/* Increment count of paths read */
@ -417,15 +417,15 @@ static Status_t read_udnpath(
/* Allocate and initialize a new node info structure */
if(n == 0)
node = (void *) malloc(sizeof(Node_Info_t));
node = (Node_Info_t *) malloc(sizeof(Node_Info_t));
else
node = (void *) realloc(node, (n + 1) * sizeof(Node_Info_t));
node = (Node_Info_t *) realloc(node, (n + 1) * sizeof(Node_Info_t));
node[n].path_name = NULL;
node[n].node_name = NULL;
node[n].unique = TRUE;
/* Put pathname into info structure */
node[n].path_name = malloc(len+1);
node[n].path_name = (char *) malloc(len+1);
strcpy(node[n].path_name, path);
/* Increment count of paths read */
@ -1075,7 +1075,7 @@ static Status_t read_udn_type_name(
fclose(fp);
if(found) {
*node_name = malloc(strlen(name) + 1);
*node_name = (char *) malloc(strlen(name) + 1);
strcpy(*node_name, name);
return(OK);
}

View File

@ -980,7 +980,7 @@ static char *data_type_to_str(Data_Type_t type)
static char *str = NULL;
if(str == NULL)
str = malloc(BASE_STR_LEN+1);
str = (char *) malloc(BASE_STR_LEN+1);
switch(type) {
@ -1023,7 +1023,7 @@ static char *port_type_to_str(Port_Type_t port)
static char *str = NULL;
if(str == NULL)
str = malloc(BASE_STR_LEN+1);
str = (char *) malloc(BASE_STR_LEN+1);
switch(port) {
@ -1086,7 +1086,7 @@ static char *gen_port_type_str(Port_Type_t port)
static char *str = NULL;
if(str == NULL)
str = malloc(BASE_STR_LEN+1);
str = (char *) malloc(BASE_STR_LEN+1);
switch(port) {
@ -1150,7 +1150,7 @@ static char *dir_to_str(Dir_t dir)
static char *str = NULL;
if(str == NULL)
str = malloc(BASE_STR_LEN+1);
str = (char *) malloc(BASE_STR_LEN+1);
switch(dir) {
@ -1187,7 +1187,7 @@ static char *value_to_str(Data_Type_t type, Value_t value)
if(str == NULL) {
str = malloc(2 * BASE_STR_LEN + 1);
str = (char *) malloc(2 * BASE_STR_LEN + 1);
max_len = 2 * BASE_STR_LEN;
}
@ -1215,7 +1215,7 @@ static char *value_to_str(Data_Type_t type, Value_t value)
/* be careful, the string could conceivably be very long... */
str_len = strlen(value.svalue);
if((str_len + BASE_STR_LEN) > max_len) {
str = realloc(str, (max_len + str_len +1));
str = (char *) realloc(str, (max_len + str_len +1));
max_len += str_len;
}
sprintf(str, "{MIF_FALSE, 0, 0.0, {0.0, 0.0}, \"%s\"}", value.svalue);
@ -1237,7 +1237,7 @@ static char *boolean_to_str(Boolean_t value)
static char *str = NULL;
if(str == NULL)
str = malloc(BASE_STR_LEN+1);
str = (char *) malloc(BASE_STR_LEN+1);
switch(value) {
@ -1267,7 +1267,7 @@ static char *integer_to_str(int value)
static char *str = NULL;
if(str == NULL) {
str = malloc(BASE_STR_LEN + 1);
str = (char *) malloc(BASE_STR_LEN + 1);
}
sprintf(str, "%d", value);
@ -1283,7 +1283,7 @@ static char *no_value_to_str(void)
static char *str = NULL;
if(str == NULL) {
str = malloc(BASE_STR_LEN + 1);
str = (char *) malloc(BASE_STR_LEN + 1);
}
sprintf(str, "{MIF_FALSE, 0, 0.0, {0.0, 0.0}, NULL}");

View File

@ -137,7 +137,7 @@ struct line * ENHtranslate_poly(
d->li_error = two2three_translate(d->li_line, &(l1->li_line), &(l2->li_line));
/* Comment out the original line */
card = (void *) MALLOC(strlen(d->li_line) + 2);
card = (char *) MALLOC(strlen(d->li_line) + 2);
strcpy(card,"*");
strcat(card, d->li_line);
d->li_line = card;
@ -365,7 +365,7 @@ static char *two2three_translate(
name = MIFgettok(&card);
/* Get output connections (2 netnames) */
out_conn = (void *) MALLOC(2 * sizeof(char *));
out_conn = (char **) MALLOC(2 * sizeof(char *));
for(i = 0; i < 2; i++)
out_conn[i] = MIFgettok(&card);
@ -383,12 +383,12 @@ static char *two2three_translate(
/* Get input connections (2 netnames per dimension) */
in_conn = (void *) MALLOC(num_conns * sizeof(char *));
in_conn = (char **) MALLOC(num_conns * sizeof(char *));
for(i = 0; i < num_conns; i++)
in_conn[i] = MIFgettok(&card);
/* The remainder of the line are the poly coeffs. */
coef = (void *) MALLOC(num_coefs * sizeof(char *));
coef = (char **) MALLOC(num_coefs * sizeof(char *));
for(i = 0; i < num_coefs; i++)
coef[i] = MIFgettok(&card);
@ -411,8 +411,8 @@ static char *two2three_translate(
/* Allocate space for the cards and write them into the strings */
*inst_card = (void *) MALLOC(inst_card_len);
*mod_card = (void *) MALLOC(mod_card_len);
*inst_card = (char *) MALLOC(inst_card_len);
*mod_card = (char *) MALLOC(mod_card_len);
strcpy(*inst_card, "a$poly$");
sprintf(*inst_card + strlen(*inst_card), "%s ", name);

View File

@ -170,7 +170,7 @@ void EVTdump(
if(firstcall) {
/* Allocate local data structure used to process nodes */
node_dict = (void *) MALLOC(num_nodes * sizeof(evtdump_dict_t));
node_dict = (evtdump_dict_t *) MALLOC(num_nodes * sizeof(evtdump_dict_t));
/* Loop through all nodes to determine which nodes should be sent. */
/* Only nodes not within subcircuits qualify. */

View File

@ -63,7 +63,7 @@ static int EVTinit_limits(CKTcircuit *ckt);
/* Adapted from SPICE 3C1 code in CKTsetup.c */
#define CKALLOC(var,size,type) \
if(size) { \
if(!(var = (void *) MALLOC((size) * sizeof(type)))) \
if(!(var = (type *) MALLOC((size) * sizeof(type)))) \
return(E_NOMEM); \
}
@ -219,7 +219,7 @@ static int EVTcheck_nodes(
analog_node = ckt->CKTnodes;
while(analog_node) {
if(strcmp(event_node->name, analog_node->name) == 0) {
errMsg = MALLOC(strlen(err_prefix) + strlen(event_node->name) +
errMsg = (char *) MALLOC(strlen(err_prefix) + strlen(event_node->name) +
strlen(err_collide) + 1);
sprintf(errMsg, "%s%s%s", err_prefix,
event_node->name,
@ -279,7 +279,7 @@ static int EVTinit_info(
/* Allocate and initialize table of inst pointers */
num_insts = ckt->evt->counts.num_insts;
CKALLOC(inst_table, num_insts, void *)
CKALLOC(inst_table, num_insts, Evt_Inst_Info_t *)
inst = ckt->evt->info.inst_list;
for(i = 0; i < num_insts; i++) {
inst_table[i] = inst;
@ -289,7 +289,7 @@ static int EVTinit_info(
/* Allocate and initialize table of node pointers */
num_nodes = ckt->evt->counts.num_nodes;
CKALLOC(node_table, num_nodes, void *)
CKALLOC(node_table, num_nodes, Evt_Node_Info_t *)
node = ckt->evt->info.node_list;
for(i = 0; i < num_nodes; i++) {
node_table[i] = node;
@ -299,7 +299,7 @@ static int EVTinit_info(
/* Allocate and initialize table of port pointers */
num_ports = ckt->evt->counts.num_ports;
CKALLOC(port_table, num_ports, void *)
CKALLOC(port_table, num_ports, Evt_Port_Info_t *)
port = ckt->evt->info.port_list;
for(i = 0; i < num_ports; i++) {
port_table[i] = port;
@ -309,7 +309,7 @@ static int EVTinit_info(
/* Allocate and initialize table of output pointers */
num_outputs = ckt->evt->counts.num_outputs;
CKALLOC(output_table, num_outputs, void *)
CKALLOC(output_table, num_outputs, Evt_Output_Info_t *)
output = ckt->evt->info.output_list;
for(i = 0; i < num_outputs; i++) {
output_table[i] = output;
@ -359,10 +359,10 @@ static int EVTinit_queue(
num_insts = ckt->evt->counts.num_insts;
inst_queue = &(ckt->evt->queue.inst);
CKALLOC(inst_queue->head, num_insts, void *)
CKALLOC(inst_queue->current, num_insts, void *)
CKALLOC(inst_queue->last_step, num_insts, void *)
CKALLOC(inst_queue->free, num_insts, void *)
CKALLOC(inst_queue->head, num_insts, Evt_Inst_Event_t *)
CKALLOC(inst_queue->current, num_insts, Evt_Inst_Event_t **)
CKALLOC(inst_queue->last_step, num_insts, Evt_Inst_Event_t **)
CKALLOC(inst_queue->free, num_insts, Evt_Inst_Event_t *)
CKALLOC(inst_queue->modified_index, num_insts, int)
CKALLOC(inst_queue->modified, num_insts, Mif_Boolean_t)
CKALLOC(inst_queue->pending_index, num_insts, int)
@ -387,10 +387,10 @@ static int EVTinit_queue(
num_outputs = ckt->evt->counts.num_outputs;
output_queue = &(ckt->evt->queue.output);
CKALLOC(output_queue->head, num_outputs, void *)
CKALLOC(output_queue->current, num_outputs, void *)
CKALLOC(output_queue->last_step, num_outputs, void *)
CKALLOC(output_queue->free, num_outputs, void *)
CKALLOC(output_queue->head, num_outputs, Evt_Output_Event_t *)
CKALLOC(output_queue->current, num_outputs, Evt_Output_Event_t **)
CKALLOC(output_queue->last_step, num_outputs, Evt_Output_Event_t **)
CKALLOC(output_queue->free, num_outputs, Evt_Output_Event_t *)
CKALLOC(output_queue->modified_index, num_outputs, int)
CKALLOC(output_queue->modified, num_outputs, Mif_Boolean_t)
CKALLOC(output_queue->pending_index, num_outputs, int)

View File

@ -278,7 +278,7 @@ int EVTiter(
/* Too many passes through loop, report problems and exit with error */
err_msg = MALLOC(10000);
err_msg = (char *) MALLOC(10000);
for(i = 0; i < output_queue->num_changed; i++) {
output_index = output_queue->changed_index[i];
port_index = output_table[output_index]->port_index;

View File

@ -351,7 +351,7 @@ static void EVTcreate_state(
else
{
new_state = (void *) MALLOC(sizeof(Evt_State_t));
new_state = (Evt_State_t *) MALLOC(sizeof(Evt_State_t));
new_state->block = (void *) MALLOC(total_size);
}
@ -401,7 +401,7 @@ static void EVTcreate_output_event(
}
else {
/* Create a new event */
event = (void *) MALLOC(sizeof(Evt_Output_Event_t));
event = (Evt_Output_Event_t *) MALLOC(sizeof(Evt_Output_Event_t));
event->next = NULL;
/* Initialize the value */
@ -453,7 +453,7 @@ static void EVTadd_msg(
msg_data->free[port_index] = msg_data->free[port_index]->next;
}
else {
*msg_ptr = (void *) MALLOC(sizeof(Evt_Msg_t));
*msg_ptr = (Evt_Msg_t *) MALLOC(sizeof(Evt_Msg_t));
}
/* Fill in the values */

View File

@ -114,12 +114,12 @@ void EVTnode_copy(
}
else
{
here = (void *) MALLOC(sizeof(Evt_Node_t));
here = (Evt_Node_t *) MALLOC(sizeof(Evt_Node_t));
*to = here;
/* Allocate/initialize the data in the new node struct */
if(num_outputs > 1)
{
here->output_value = (void *) MALLOC(num_outputs * sizeof(void *));
here->output_value = (void **) MALLOC(num_outputs * sizeof(void *));
for(i = 0; i < num_outputs; i++)
{

View File

@ -178,7 +178,7 @@ int EVTop(
"Too many analog/event-driven solution alternations",
(IFuid *) NULL);
err_msg = MALLOC(10000);
err_msg = (char *) MALLOC(10000);
output_queue = &(ckt->evt->queue.output);
output_table = ckt->evt->info.output_table;
port_table = ckt->evt->info.port_table;

View File

@ -194,7 +194,7 @@ struct dvec *EVTfindvec(
/* Allocate dvec structures and assign the vectors into them. */
/* See FTE/OUTinterface.c:plotInit() for initialization example. */
scale = (void *) MALLOC(sizeof(struct dvec));
scale = (struct dvec *) MALLOC(sizeof(struct dvec));
scale->v_name = MIFcopy("step");
scale->v_type = SV_TIME;
@ -203,7 +203,7 @@ struct dvec *EVTfindvec(
scale->v_realdata = anal_point_vec;
scale->v_scale = NULL;
d = (void *) MALLOC(sizeof(struct dvec));
d = (struct dvec *) MALLOC(sizeof(struct dvec));
d->v_name = name;
d->v_type = SV_VOLTAGE;

View File

@ -204,7 +204,7 @@ void EVTqueue_inst(
inst_queue->free[inst_index] = new_event->next;
}
else {
new_event = (void *) MALLOC(sizeof(Evt_Inst_Event_t));
new_event = (Evt_Inst_Event_t *) MALLOC(sizeof(Evt_Inst_Event_t));
}
new_event->event_time = event_time;
new_event->posted_time = posted_time;

View File

@ -72,16 +72,16 @@ static int EVTsetup_load_ptrs(CKTcircuit *ckt);
#define CKALLOC(var,size,type) \
if(size) { \
if(!(var = (void *) MALLOC((size) * sizeof(type)))) \
if(!(var = (type *) MALLOC((size) * sizeof(type)))) \
return(E_NOMEM); \
}
#define CKREALLOC(var,size,type) \
if((size) == 1) { \
if(!(var = (void *) MALLOC((size) * sizeof(type)))) \
if(!(var = (type *) MALLOC((size) * sizeof(type)))) \
return(E_NOMEM); \
} else if((size) > 1) { \
if(!(var = (void *) REALLOC((void *) (var), (size) * sizeof(type)))) \
if(!(var = (type *) REALLOC((void *) (var), (size) * sizeof(type)))) \
return(E_NOMEM); \
}
@ -320,10 +320,10 @@ static int EVTsetup_data(
num_nodes = ckt->evt->counts.num_nodes;
node_data = data->node;
CKALLOC(node_data->head, num_nodes, void *)
CKALLOC(node_data->tail, num_nodes, void *)
CKALLOC(node_data->last_step, num_nodes, void *)
CKALLOC(node_data->free, num_nodes, void *)
CKALLOC(node_data->head, num_nodes, Evt_Node_t *)
CKALLOC(node_data->tail, num_nodes, Evt_Node_t **)
CKALLOC(node_data->last_step, num_nodes, Evt_Node_t **)
CKALLOC(node_data->free, num_nodes, Evt_Node_t *)
CKALLOC(node_data->modified_index, num_nodes, int)
CKALLOC(node_data->modified, num_nodes, Mif_Boolean_t)
CKALLOC(node_data->rhs, num_nodes, Evt_Node_t)
@ -382,14 +382,14 @@ static int EVTsetup_data(
num_insts = ckt->evt->counts.num_insts;
state_data = data->state;
CKALLOC(state_data->head, num_insts, void *)
CKALLOC(state_data->tail, num_insts, void *)
CKALLOC(state_data->last_step, num_insts, void *)
CKALLOC(state_data->free, num_insts, void *)
CKALLOC(state_data->head, num_insts, Evt_State_t *)
CKALLOC(state_data->tail, num_insts, Evt_State_t **)
CKALLOC(state_data->last_step, num_insts, Evt_State_t **)
CKALLOC(state_data->free, num_insts, Evt_State_t *)
CKALLOC(state_data->modified_index, num_insts, int)
CKALLOC(state_data->modified, num_insts, Mif_Boolean_t)
CKALLOC(state_data->total_size, num_insts, int)
CKALLOC(state_data->desc, num_insts, void *)
CKALLOC(state_data->desc, num_insts, Evt_State_Desc_t *)
for(i = 0; i < num_insts; i++) {
state_data->tail[i] = &(state_data->head[i]);
@ -402,10 +402,10 @@ static int EVTsetup_data(
num_ports = ckt->evt->counts.num_ports;
msg_data = data->msg;
CKALLOC(msg_data->head, num_ports, void *)
CKALLOC(msg_data->tail, num_ports, void *)
CKALLOC(msg_data->last_step, num_ports, void *)
CKALLOC(msg_data->free, num_ports, void *)
CKALLOC(msg_data->head, num_ports, Evt_Msg_t *)
CKALLOC(msg_data->tail, num_ports, Evt_Msg_t **)
CKALLOC(msg_data->last_step, num_ports, Evt_Msg_t **)
CKALLOC(msg_data->free, num_ports, Evt_Msg_t *)
CKALLOC(msg_data->modified_index, num_ports, int)
CKALLOC(msg_data->modified, num_ports, Mif_Boolean_t)
@ -448,11 +448,11 @@ static int EVTsetup_jobs(
num_jobs = ++(jobs->num_jobs);
/* Allocate/reallocate necessary pointers */
CKREALLOC(jobs->job_name, num_jobs, void *)
CKREALLOC(jobs->node_data, num_jobs, void *)
CKREALLOC(jobs->state_data, num_jobs, void *)
CKREALLOC(jobs->msg_data, num_jobs, void *)
CKREALLOC(jobs->statistics, num_jobs, void *)
CKREALLOC(jobs->job_name, num_jobs, char *)
CKREALLOC(jobs->node_data, num_jobs, Evt_Node_Data_t *)
CKREALLOC(jobs->state_data, num_jobs, Evt_State_Data_t *)
CKREALLOC(jobs->msg_data, num_jobs, Evt_Msg_Data_t *)
CKREALLOC(jobs->statistics, num_jobs, Evt_Statistic_t *)
/* Fill in the pointers, etc. for this new job */
i = num_jobs - 1;

View File

@ -212,7 +212,7 @@ static void EVTinst_insert(
/* If not found, create a new entry in list and increment the */
/* instance count in the event structure */
if(! found) {
*inst_ptr = (void *) MALLOC(sizeof(Evt_Inst_Info_t));
*inst_ptr = (Evt_Inst_Info_t *) MALLOC(sizeof(Evt_Inst_Info_t));
inst = *inst_ptr;
inst->next = NULL;
inst->inst_ptr = fast;
@ -325,7 +325,7 @@ static void EVTnode_insert(
/* If not found, create a new entry in list and increment the */
/* node count in the event structure */
if(! found) {
*node_ptr = (void *) MALLOC(sizeof(Evt_Node_Info_t));
*node_ptr = (Evt_Node_Info_t *) MALLOC(sizeof(Evt_Node_Info_t));
node = *node_ptr;
node->next = NULL;
node->name = MIFcopy(node_name);
@ -370,7 +370,7 @@ static void EVTnode_insert(
if(! found) {
(node->num_insts)++;
*inst_ptr = (void *) MALLOC(sizeof(Evt_Inst_Index_t));
*inst_ptr = (Evt_Inst_Index_t *) MALLOC(sizeof(Evt_Inst_Index_t));
inst = *inst_ptr;
inst->next = NULL;
inst->index = inst_index;
@ -431,7 +431,7 @@ static void EVTport_insert(
(ckt->evt->counts.num_ports)++;
*port_ptr = (void *) MALLOC(sizeof(Evt_Port_Info_t));
*port_ptr = (Evt_Port_Info_t *) MALLOC(sizeof(Evt_Port_Info_t));
port = *port_ptr;
/* Fill in the elements */
@ -493,7 +493,7 @@ static void EVToutput_insert(
(ckt->evt->counts.num_outputs)++;
*output_ptr = (void *) MALLOC(sizeof(Evt_Output_Info_t));
*output_ptr = (Evt_Output_Info_t *) MALLOC(sizeof(Evt_Output_Info_t));
output = *output_ptr;
/* Fill in the elements */

View File

@ -154,7 +154,7 @@ static char *CNVgettok(char **s)
/* allocate space big enough for the whole string */
buf = (void *) malloc(strlen(*s) + 1);
buf = (char *) malloc(strlen(*s) + 1);
/* skip over any white space */
@ -197,7 +197,7 @@ static char *CNVgettok(char **s)
/* make a copy using only the space needed by the string length */
ret_str = (void *) malloc(strlen(buf) + 1);
ret_str = (char *) malloc(strlen(buf) + 1);
ret_str = strcpy(ret_str,buf);
if(buf) free(buf);

View File

@ -213,7 +213,7 @@ static char *CNVgettok(char **s)
/* allocate space big enough for the whole string */
buf = (void *) malloc(strlen(*s) + 1);
buf = (char *) malloc(strlen(*s) + 1);
/* skip over any white space */
@ -256,7 +256,7 @@ static char *CNVgettok(char **s)
/* make a copy using only the space needed by the string length */
ret_str = (void *) malloc(strlen(buf) + 1);
ret_str = (char *) malloc(strlen(buf) + 1);
ret_str = strcpy(ret_str,buf);
if(buf) free(buf);

View File

@ -100,7 +100,7 @@ void spice2poly (ARGS)
/* array */
if(INIT) {
acgains = malloc(num_inputs * sizeof(double));
acgains = (double *) malloc(num_inputs * sizeof(double));
for(i = 0; i < num_inputs; i++)
acgains[i] = 0.0;
STATIC_VAR(acgains) = acgains;
@ -122,19 +122,19 @@ void spice2poly (ARGS)
/* Get input values and coefficients to local storage for faster access */
in = malloc(num_inputs * sizeof(double));
in = (double *) malloc(num_inputs * sizeof(double));
for(i = 0; i < num_inputs; i++)
in[i] = INPUT(in[i]);
num_coefs = PARAM_SIZE(coef);
coef = malloc(num_coefs * sizeof(double));
coef = (double *) malloc(num_coefs * sizeof(double));
for(i = 0; i < num_coefs; i++)
coef[i] = PARAM(coef[i]);
/* Allocate the array of exponents used in computing the poly terms */
exp = malloc(num_inputs * sizeof(int));
exp = (int *) malloc(num_inputs * sizeof(int));
/* Initialize the exponents to zeros */
for(i = 0; i < num_inputs; i++)

View File

@ -152,7 +152,7 @@ void udn_int_print_val(PRINT_VAL_ARGS)
int *int_struct = STRUCT_PTR;
/* Allocate space for the printed value */
PRINT_VAL = tmalloc(30);
PRINT_VAL = (char *) tmalloc(30);
/* Print the value into the string */
sprintf(PRINT_VAL, "%8d", *int_struct);

View File

@ -155,7 +155,7 @@ void udn_real_print_val(PRINT_VAL_ARGS)
/* Allocate space for the printed value */
PRINT_VAL = tmalloc(30);
PRINT_VAL = (char *) tmalloc(30);
/* Print the value into the string */
sprintf(PRINT_VAL, "%15.6e", *real_struct);

View File

@ -159,8 +159,8 @@ void ipc_handle_vtrans(
if(g_ipc.vtrans.size == 0) {
g_ipc.vtrans.size = 1;
g_ipc.vtrans.vsrc_name = (void *) MALLOC(sizeof(char *));
g_ipc.vtrans.device_name = (void *) MALLOC(sizeof(char *));
g_ipc.vtrans.vsrc_name = (char **) MALLOC(sizeof(char *));
g_ipc.vtrans.device_name = (char **) MALLOC(sizeof(char *));
g_ipc.vtrans.vsrc_name[0] = MIFcopy(vsrc);
g_ipc.vtrans.device_name[0] = MIFcopy(dev);
}
@ -170,9 +170,9 @@ void ipc_handle_vtrans(
size = g_ipc.vtrans.size;
i = g_ipc.vtrans.size - 1;
g_ipc.vtrans.vsrc_name = (void *) REALLOC(g_ipc.vtrans.vsrc_name,
g_ipc.vtrans.vsrc_name = (char **) REALLOC(g_ipc.vtrans.vsrc_name,
size * sizeof(char *));
g_ipc.vtrans.device_name = (void *) REALLOC(g_ipc.vtrans.device_name,
g_ipc.vtrans.device_name = (char **) REALLOC(g_ipc.vtrans.device_name,
size * sizeof(char *));
g_ipc.vtrans.vsrc_name[i] = MIFcopy(vsrc);
g_ipc.vtrans.device_name[i] = MIFcopy(dev);

View File

@ -561,10 +561,10 @@ static void MIFinit_inst(
/* allocate code model connector data in instance struct */
fast->num_conn = DEVices[mod_type]->DEVpublic.num_conn;
fast->conn = (void *) tmalloc(fast->num_conn * sizeof(void *));
fast->conn = (Mif_Conn_Data_t **) tmalloc(fast->num_conn * sizeof(Mif_Conn_Data_t *));
for(i = 0; i < fast->num_conn; i++)
fast->conn[i] = (void *) tmalloc(sizeof(Mif_Conn_Data_t));
fast->conn[i] = (Mif_Conn_Data_t *) tmalloc(sizeof(Mif_Conn_Data_t));
/* initialize code model connector data */
for(i = 0; i < fast->num_conn; i++) {
@ -597,11 +597,11 @@ static void MIFinit_inst(
/* allocate and copy instance variable data to the instance */
fast->num_inst_var = DEVices[mod_type]->DEVpublic.num_inst_var;
fast->inst_var = (void *) tmalloc(fast->num_inst_var * sizeof(void *));
fast->inst_var = (Mif_Inst_Var_Data_t **) tmalloc(fast->num_inst_var * sizeof(Mif_Inst_Var_Data_t *));
for(i = 0; i < fast->num_inst_var; i++) {
fast->inst_var[i] = (void *) tmalloc(sizeof(Mif_Inst_Var_Data_t));
fast->inst_var[i] = (Mif_Inst_Var_Data_t *) tmalloc(sizeof(Mif_Inst_Var_Data_t));
if(DEVices[mod_type]->DEVpublic.inst_var[i].is_array) {
fast->inst_var[i]->size = 0;
@ -610,7 +610,7 @@ static void MIFinit_inst(
}
else {
fast->inst_var[i]->size = 1;
fast->inst_var[i]->element = (void *) tmalloc(sizeof(Mif_Value_t));
fast->inst_var[i]->element = (Mif_Value_t *) tmalloc(sizeof(Mif_Value_t));
}
}
@ -771,14 +771,14 @@ MIFget_port(
/* allocate space in the instance data struct for this port */
if(port_num == 0) {
fast->conn[conn_num]->port = (void *) tmalloc(sizeof(void *));
fast->conn[conn_num]->port[0] = (void *) tmalloc(sizeof(Mif_Port_Data_t));
fast->conn[conn_num]->port = (Mif_Port_Data_t **) tmalloc(sizeof(Mif_Port_Data_t *));
fast->conn[conn_num]->port[0] = (Mif_Port_Data_t *) tmalloc(sizeof(Mif_Port_Data_t));
}
else {
fast->conn[conn_num]->port = (void *) REALLOC(
fast->conn[conn_num]->port = (Mif_Port_Data_t **) REALLOC(
fast->conn[conn_num]->port,
((port_num + 1) * sizeof(void *)) );
fast->conn[conn_num]->port[port_num] = (void *) tmalloc(sizeof(Mif_Port_Data_t));
((port_num + 1) * sizeof(Mif_Port_Data_t *)) );
fast->conn[conn_num]->port[port_num] = (Mif_Port_Data_t *) tmalloc(sizeof(Mif_Port_Data_t));
}

View File

@ -177,7 +177,7 @@ int MIFask(
case IF_FLAGVEC:
if(size <= 0)
break;
value->v.vec.iVec = (void *) MALLOC(size * sizeof(int));
value->v.vec.iVec = (int *) MALLOC(size * sizeof(int));
for(i = 0; i < size; i++)
value->v.vec.iVec[i] = inst->inst_var[inst_index]->element[i].bvalue;
break;
@ -185,7 +185,7 @@ int MIFask(
case IF_INTVEC:
if(size <= 0)
break;
value->v.vec.iVec = (void *) MALLOC(size * sizeof(int));
value->v.vec.iVec = (int *) MALLOC(size * sizeof(int));
for(i = 0; i < size; i++)
value->v.vec.iVec[i] = inst->inst_var[inst_index]->element[i].ivalue;
break;
@ -193,7 +193,7 @@ int MIFask(
case IF_REALVEC:
if(size <= 0)
break;
value->v.vec.rVec = (void *) MALLOC(size * sizeof(double));
value->v.vec.rVec = (double *) MALLOC(size * sizeof(double));
for(i = 0; i < size; i++)
value->v.vec.rVec[i] = inst->inst_var[inst_index]->element[i].rvalue;
break;
@ -201,7 +201,7 @@ int MIFask(
case IF_STRINGVEC:
if(size <= 0)
break;
value->v.vec.sVec = (void *) MALLOC(size * sizeof(char *));
value->v.vec.sVec = (char **) MALLOC(size * sizeof(char *));
for(i = 0; i < size; i++)
/* Make copy of string. We don't trust caller to not free it */
/* These copies could get expensive! */
@ -213,7 +213,7 @@ int MIFask(
break;
/* we don't trust the caller to have a parallel complex structure */
/* so copy the real and imaginary parts explicitly */
value->v.vec.cVec = (void *) MALLOC(size * sizeof(IFcomplex));
value->v.vec.cVec = (IFcomplex *) MALLOC(size * sizeof(IFcomplex));
for(i = 0; i < size; i++) {
value->v.vec.cVec[i].real = inst->inst_var[inst_index]->element[i].cvalue.real;
value->v.vec.cVec[i].imag = inst->inst_var[inst_index]->element[i].cvalue.imag;

View File

@ -171,9 +171,9 @@ char *MIFgetMod(
/* gtri modification: allocate and initialize MIF specific model struct items */
mdfast = (MIFmodel*) modtmp->INPmodfast;
mdfast->num_param = DEVices[modtmp->INPmodType]->DEVpublic.num_param;
mdfast->param = (void *) tmalloc(mdfast->num_param * sizeof(void *));
mdfast->param = (Mif_Param_Data_t **) tmalloc(mdfast->num_param * sizeof(Mif_Param_Data_t *));
for(i = 0; i < mdfast->num_param; i++) {
mdfast->param[i] = (void *) tmalloc(sizeof(Mif_Param_Data_t));
mdfast->param[i] = (Mif_Param_Data_t *) tmalloc(sizeof(Mif_Param_Data_t));
mdfast->param[i]->is_null = MIF_TRUE;
mdfast->param[i]->size = 0;
mdfast->param[i]->element = NULL;
@ -201,7 +201,7 @@ char *MIFgetMod(
INPmodType ]).modelParms[j].
dataType),tab,&err1);
if(err1) {
err2 = (void *) tmalloc(25 + strlen(name) + strlen(err1));
err2 = (char *) tmalloc(25 + strlen(name) + strlen(err1));
sprintf(err2, "MIF-ERROR - model: %s - %s\n", name, err1);
return(err2);
}

View File

@ -120,7 +120,7 @@ MIFgetValue (
return(NULL);
}
val.v.numValue = 0;
val.v.vec.iVec = (void *) MALLOC(1); /* just so that realloc doesn't bomb */
val.v.vec.iVec = (int *) MALLOC(1); /* just so that realloc doesn't bomb */
}
@ -171,7 +171,7 @@ MIFgetValue (
case IF_FLAGVEC:
btemp = MIFget_boolean(token, err);
val.v.vec.iVec = (void *) REALLOC(val.v.vec.iVec,
val.v.vec.iVec = (int *) REALLOC(val.v.vec.iVec,
(val.v.numValue + 1) * sizeof(int));
val.v.vec.iVec[val.v.numValue] = btemp;
val.v.numValue++;
@ -179,7 +179,7 @@ MIFgetValue (
case IF_INTVEC:
itemp = MIFget_integer(token, err);
val.v.vec.iVec = (void *) REALLOC(val.v.vec.iVec,
val.v.vec.iVec = (int *) REALLOC(val.v.vec.iVec,
(val.v.numValue + 1) * sizeof(int));
val.v.vec.iVec[val.v.numValue] = itemp;
val.v.numValue++;
@ -187,7 +187,7 @@ MIFgetValue (
case IF_REALVEC:
rtemp = MIFget_real(token, err);
val.v.vec.rVec = (void *) REALLOC(val.v.vec.rVec,
val.v.vec.rVec = (double *) REALLOC(val.v.vec.rVec,
(val.v.numValue + 1) * sizeof(double));
val.v.vec.rVec[val.v.numValue] = rtemp;
val.v.numValue++;
@ -195,7 +195,7 @@ MIFgetValue (
case IF_STRINGVEC:
stemp = MIFget_string(token, err);
val.v.vec.sVec = (void *) REALLOC(val.v.vec.sVec,
val.v.vec.sVec = (char **) REALLOC(val.v.vec.sVec,
(val.v.numValue + 1) * sizeof(char *));
val.v.vec.sVec[val.v.numValue] = stemp;
val.v.numValue++;
@ -203,7 +203,7 @@ MIFgetValue (
case IF_CPLXVEC:
ctemp = MIFget_complex(token, token_type, line, err);
val.v.vec.cVec = (void *) REALLOC(val.v.vec.cVec,
val.v.vec.cVec = (IFcomplex *) REALLOC(val.v.vec.cVec,
(val.v.numValue + 1) * sizeof(IFcomplex));
val.v.vec.cVec[val.v.numValue] = ctemp;
val.v.numValue++;

View File

@ -166,7 +166,7 @@ int MIFmAsk(
case IF_FLAGVEC:
if(size <= 0)
break;
value->v.vec.iVec = (void *) MALLOC(size * sizeof(int));
value->v.vec.iVec = (int *) MALLOC(size * sizeof(int));
for(i = 0; i < size; i++)
value->v.vec.iVec[i] = model->param[param_index]->element[i].bvalue;
break;
@ -174,7 +174,7 @@ int MIFmAsk(
case IF_INTVEC:
if(size <= 0)
break;
value->v.vec.iVec = (void *) MALLOC(size * sizeof(int));
value->v.vec.iVec = (int *) MALLOC(size * sizeof(int));
for(i = 0; i < size; i++)
value->v.vec.iVec[i] = model->param[param_index]->element[i].ivalue;
break;
@ -182,7 +182,7 @@ int MIFmAsk(
case IF_REALVEC:
if(size <= 0)
break;
value->v.vec.rVec = (void *) MALLOC(size * sizeof(double));
value->v.vec.rVec = (double *) MALLOC(size * sizeof(double));
for(i = 0; i < size; i++)
value->v.vec.rVec[i] = model->param[param_index]->element[i].rvalue;
break;
@ -190,7 +190,7 @@ int MIFmAsk(
case IF_STRINGVEC:
if(size <= 0)
break;
value->v.vec.sVec = (void *) MALLOC(size * sizeof(char *));
value->v.vec.sVec = (char **) MALLOC(size * sizeof(char *));
for(i = 0; i < size; i++)
/* Make copy of string. We don't trust caller to not free it */
/* These copies could get expensive! */
@ -202,7 +202,7 @@ int MIFmAsk(
break;
/* we don't trust the caller to have a parallel complex structure */
/* so copy the real and imaginary parts explicitly */
value->v.vec.cVec = (void *) MALLOC(size * sizeof(IFcomplex));
value->v.vec.cVec = (IFcomplex *) MALLOC(size * sizeof(IFcomplex));
for(i = 0; i < size; i++) {
value->v.vec.cVec[i].real = model->param[param_index]->element[i].cvalue.real;
value->v.vec.cVec[i].imag = model->param[param_index]->element[i].cvalue.imag;

View File

@ -118,12 +118,12 @@ int MIFmParam(
model->param[param_index]->is_null = MIF_FALSE;
if(is_array) {
model->param[param_index]->size = value->v.numValue;
model->param[param_index]->element = (void *) MALLOC(value->v.numValue *
model->param[param_index]->element = (Mif_Value_t *) MALLOC(value->v.numValue *
sizeof(Mif_Value_t));
}
else {
model->param[param_index]->size = 1;
model->param[param_index]->element = (void *) MALLOC(sizeof(Mif_Value_t));
model->param[param_index]->element = (Mif_Value_t *) MALLOC(sizeof(Mif_Value_t));
}
@ -150,7 +150,7 @@ int MIFmParam(
case IF_STRING:
/* we don't trust the caller to keep the string alive, so copy it */
model->param[param_index]->element[0].svalue =
(void *) MALLOC(1 + strlen(value->sValue));
(char *) MALLOC(1 + strlen(value->sValue));
strcpy(model->param[param_index]->element[0].svalue, value->sValue);
break;
@ -187,7 +187,7 @@ int MIFmParam(
case IF_STRINGVEC:
/* we don't trust the caller to keep the string alive, so copy it */
model->param[param_index]->element[i].svalue =
(void *) MALLOC(1 + strlen(value->v.vec.sVec[i]));
(char *) MALLOC(1 + strlen(value->v.vec.sVec[i]));
strcpy(model->param[param_index]->element[i].svalue, value->v.vec.sVec[i]);
break;

View File

@ -153,7 +153,7 @@ MIFsetup(
/* determine the size and allocate the parameter element(s) */
if(! param_info->is_array) {
model->param[i]->size = 1;
model->param[i]->element = (void *) MALLOC(sizeof(Mif_Value_t));
model->param[i]->element = (Mif_Value_t *) MALLOC(sizeof(Mif_Value_t));
}
else { /* parameter is an array */
/* MIF_INP2A() parser assures that there is an associated array connection */
@ -166,7 +166,7 @@ MIFsetup(
max_size = size;
}
model->param[i]->size = max_size;
model->param[i]->element = (void *) MALLOC(max_size * sizeof(Mif_Value_t));
model->param[i]->element = (Mif_Value_t *) MALLOC(max_size * sizeof(Mif_Value_t));
} /* end if parameter is an array */
/* set the parameter element(s) to default value */
@ -235,21 +235,21 @@ MIFsetup(
num_port = here->conn[i]->size;
for(j = 0; j < num_port; j++) {
here->conn[i]->port[j]->partial =
(void *) MALLOC(num_conn * sizeof(Mif_Partial_t));
(Mif_Partial_t *) MALLOC(num_conn * sizeof(Mif_Partial_t));
here->conn[i]->port[j]->ac_gain =
(void *) MALLOC(num_conn * sizeof(Mif_AC_Gain_t));
(Mif_AC_Gain_t *) MALLOC(num_conn * sizeof(Mif_AC_Gain_t));
here->conn[i]->port[j]->smp_data.input =
(void *) MALLOC(num_conn * sizeof(Mif_Conn_Ptr_t));
(Mif_Conn_Ptr_t *) MALLOC(num_conn * sizeof(Mif_Conn_Ptr_t));
for(k = 0; k < num_conn; k++) {
if((here->conn[k]->is_null) || (! here->conn[k]->is_input) )
continue;
num_port_k = here->conn[k]->size;
here->conn[i]->port[j]->partial[k].port =
(void *) MALLOC(num_port_k * sizeof(double));
(double *) MALLOC(num_port_k * sizeof(double));
here->conn[i]->port[j]->ac_gain[k].port =
(void *) MALLOC(num_port_k * sizeof(Mif_Complex_t));
(Mif_Complex_t *) MALLOC(num_port_k * sizeof(Mif_Complex_t));
here->conn[i]->port[j]->smp_data.input[k].port =
(void *) MALLOC(num_port_k * sizeof(Mif_Port_Ptr_t));
(Mif_Port_Ptr_t *) MALLOC(num_port_k * sizeof(Mif_Port_Ptr_t));
}
}
}
@ -310,7 +310,7 @@ MIFsetup(
(type == MIF_RESISTANCE || type == MIF_DIFF_RESISTANCE) ) {
/* first, make the current equation */
suffix = (void *) MALLOC(strlen((char *) here->MIFname) + 100);
suffix = (char *) MALLOC(strlen((char *) here->MIFname) + 100);
sprintf(suffix, "branch_%d_%d", i, j);
error = CKTmkCur(ckt, &tmp, here->MIFname, suffix);
FREE(suffix);
@ -333,7 +333,7 @@ MIFsetup(
if(is_input && (type == MIF_CURRENT || type == MIF_DIFF_CURRENT)) {
/* first, make the current equation */
suffix = (void *) MALLOC(strlen((char *) here->MIFname) + 100);
suffix = (char *) MALLOC(strlen((char *) here->MIFname) + 100);
sprintf(suffix, "ibranch_%d_%d", i, j);
error = CKTmkCur(ckt, &tmp, here->MIFname, suffix);
FREE(suffix);

View File

@ -76,7 +76,7 @@ char *MIFgettok(char **s)
/* allocate space big enough for the whole string */
buf = (void *) MALLOC(strlen(*s) + 1);
buf = (char *) MALLOC(strlen(*s) + 1);
/* skip over any white space */