link.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "link.h"
#include "defines.h"
#include "vsignal.h"
#include "expr.h"
#include "func_unit.h"
#include "util.h"
#include "statement.h"
#include "fsm.h"
#include "gen_item.h"
#include "obfuscate.h"
#include "instance.h"

Functions

str_linkstr_link_add (char *str, str_link **head, str_link **tail)
 Adds specified string to str_link element at the end of the list.
stmt_linkstmt_link_add (statement *stmt, bool rm_stmt, stmt_link **head, stmt_link **tail)
 Adds specified statement to stmt_link element at the beginning of the list.
void exp_link_add (expression *expr, exp_link **head, exp_link **tail)
 Adds specified expression to exp_link element at the end of the list.
void sig_link_add (vsignal *sig, sig_link **head, sig_link **tail)
 Adds specified signal to sig_link element at the end of the list.
void fsm_link_add (fsm *table, fsm_link **head, fsm_link **tail)
 Adds specified FSM to fsm_link element at the end of the list.
void funit_link_add (func_unit *funit, funit_link **head, funit_link **tail)
 Adds specified functional unit to funit_link element at the end of the list.
void gitem_link_add (gen_item *gi, gitem_link **head, gitem_link **tail)
 Adds specified generate item to the end of specified gitem list.
inst_linkinst_link_add (funit_inst *inst, inst_link **head, inst_link **tail)
 Adds specified functional unit instance to inst_link element at the end of the list.
void str_link_display (str_link *head)
 Displays specified string list to standard output.
void stmt_link_display (stmt_link *head)
 Displays specified statement list to standard output.
void exp_link_display (exp_link *head)
 Displays specified expression list to standard output.
void sig_link_display (sig_link *head)
 Displays specified signal list to standard output.
void funit_link_display (funit_link *head)
 Displays specified functional unit list to standard output.
void gitem_link_display (gitem_link *head)
 Displays specified generate item list to standard output.
void inst_link_display (inst_link *head)
 Displays specified instance list to standard output.
str_linkstr_link_find (const char *value, str_link *head)
 Finds specified string in the given str_link list.
stmt_linkstmt_link_find (int id, stmt_link *head)
 Finds specified statement in the given stmt_link list.
stmt_linkstmt_link_find_by_pos (unsigned int ppline, uint32 first_col, stmt_link *head)
 Finds specified statement in the given stmt_link list.
exp_linkexp_link_find (int id, exp_link *head)
 Finds specified expression in the given exp_link list.
exp_linkexp_link_find_by_pos (exp_op_type op, int line, uint32 col, exp_link *head)
sig_linksig_link_find (const char *name, sig_link *head)
 Finds specified signal in given sig_link list.
fsm_linkfsm_link_find (const char *name, fsm_link *head)
 Finds specified FSM structure in fsm_link list.
fsm_linkfsm_link_find_by_pos (int line, fsm_link *head)
 Finds specified FSM structure in fsm_link list based on file position.
funit_linkfunit_link_find (const char *name, int type, funit_link *head)
 Finds specified functional unit in given funit_link list.
gitem_linkgitem_link_find (gen_item *gi, gitem_link *head)
 Finds specified generate item in given gitem_link list.
funit_instinst_link_find_by_scope (char *scope, inst_link *head)
 Finds specified functional unit instance in given inst_link list.
funit_instinst_link_find_by_funit (const func_unit *funit, inst_link *head, int *ignore)
 Finds specified functional unit instance in given inst_link list.
void str_link_remove (char *str, str_link **head, str_link **tail)
 Searches for and removes specified string link from list.
void exp_link_remove (expression *exp, exp_link **head, exp_link **tail, bool recursive)
 Searches for and removes specified expression link from list.
void gitem_link_remove (gen_item *gi, gitem_link **head, gitem_link **tail)
 Searches for and removes specified generate item link from list.
void funit_link_remove (func_unit *funit, funit_link **head, funit_link **tail, bool rm_funit)
 Searches for and removes specified functional unit link from list.
void str_link_delete_list (str_link *head)
 Deletes entire list specified by head pointer.
void stmt_link_unlink (statement *stmt, stmt_link **head, stmt_link **tail)
 Unlinks the stmt_link specified by the specified statement.
void stmt_link_delete_list (stmt_link *head)
 Deletes entire list specified by head pointer.
void exp_link_delete_list (exp_link *head, bool del_exp)
 Deletes entire list specified by head pointer.
void sig_link_delete_list (sig_link *head, bool del_sig)
 Deletes entire list specified by head pointer.
void fsm_link_delete_list (fsm_link *head)
 Deletes entire list specified by head pointer.
void funit_link_delete_list (funit_link **head, funit_link **tail, bool rm_funit)
 Deletes entire list specified by head pointer.
void gitem_link_delete_list (gitem_link *head, bool rm_elems)
 Deletes entire list specified by head pointer.
void inst_link_delete_list (inst_link *head)
 Deletes entire list specified by head pointer.

Detailed Description

Author:
Trevor Williams (phase1geo@gmail.com)
Date:
11/28/2001

Function Documentation

void exp_link_add ( expression expr,
exp_link **  head,
exp_link **  tail 
)

Adds specified expression to exp_link element at the end of the list.

Creates a new exp_link element with the value specified for expr. Sets next pointer of element to NULL, sets the tail element to point to the new element and sets the tail value to the new element.

Parameters:
expr Expression to add to specified expression list
head Pointer to head exp_link element of list
tail Pointer to tail exp_link element of list

References exp_link_s::exp, malloc_safe, exp_link_s::next, PROFILE, and PROFILE_END.

Referenced by bind_param(), bind_signal(), bind_task_function_namedblock(), db_add_expression(), expression_db_read(), expression_find_params(), fsm_arg_parse_value(), fsm_var_add_expr(), inst_parm_add(), param_find_and_set_expr_value(), vsignal_add_expression(), and vsignal_duplicate().

00151   { PROFILE(EXP_LINK_ADD);
00152 
00153   exp_link* tmp;  /* Temporary pointer to newly created exp_link element */
00154 
00155   tmp = (exp_link*)malloc_safe( sizeof( exp_link ) );
00156 
00157   tmp->exp  = expr;
00158   tmp->next = NULL;
00159 
00160   if( *head == NULL ) {
00161     *head = *tail = tmp;
00162   } else {
00163     (*tail)->next = tmp;
00164     *tail         = tmp;
00165   }
00166 
00167   PROFILE_END;
00168 
00169 }

void exp_link_delete_list ( exp_link head,
bool  del_exp 
)

Deletes entire list specified by head pointer.

Deletes each element of the specified list.

Parameters:
head Pointer to head exp_link element of list
del_exp If set to TRUE, deallocates the expression; otherwise, leaves expression alone

References exp_link_s::exp, expression_dealloc(), free_safe, exp_link_s::next, PROFILE, PROFILE_END, and TRUE.

Referenced by funit_clean(), mod_parm_dealloc(), sim_add_statics(), sim_dealloc(), and vsignal_dealloc().

01092   { PROFILE(EXP_LINK_DELETE_LIST);
01093 
01094   exp_link* tmp;  /* Pointer to current expression link to remove */
01095   
01096   while( head != NULL ) {
01097 
01098     tmp  = head;
01099     head = head->next;
01100     
01101     /* Deallocate expression */
01102     if( del_exp ) {
01103       expression_dealloc( tmp->exp, TRUE );
01104       tmp->exp = NULL;
01105     }
01106     
01107     /* Deallocate exp_link element itself */
01108     free_safe( tmp, sizeof( exp_link ) );
01109     
01110   }
01111 
01112   PROFILE_END;
01113 
01114 }

void exp_link_display ( exp_link head  ) 

Displays specified expression list to standard output.

Displays the string contents of the exp_link list pointed to by head to standard output. This function is mainly used for debugging purposes.

Parameters:
head Pointer to head of exp_link list

References exp_link_s::exp, expression_string_op(), expression_s::id, expression_s::line, exp_link_s::next, and expression_s::op.

Referenced by mod_parm_display().

00374   {
00375 
00376   exp_link* curr;    /* Pointer to current expression link */
00377 
00378   printf( "Expression list:\n" );
00379 
00380   curr = head;
00381   while( curr != NULL ) {
00382     printf( "  id: %d, op: %s, line: %d\n", curr->exp->id, expression_string_op( curr->exp->op ), curr->exp->line );
00383     curr = curr->next;
00384   }
00385 
00386 }

exp_link* exp_link_find ( int  id,
exp_link head 
)

Finds specified expression in the given exp_link list.

Returns:
Returns the pointer to the found exp_link or NULL if the search was unsuccessful.

Iteratively searches the exp_link list specified by the head exp_link element. If a matching expression is found, the pointer to this element is returned. If the specified expression could not be matched, the value of NULL is returned.

Parameters:
id Expression ID to find
head Pointer to head of exp_link list to search

References exp_link_s::exp, expression_s::id, exp_link_s::next, PROFILE, and PROFILE_END.

Referenced by combination_get_coverage(), combination_get_expression(), expression_db_read(), fsm_db_read(), fsm_var_add_expr(), funit_find_by_id(), param_find_and_set_expr_value(), and statement_db_read().

00558   { PROFILE(EXP_LINK_FIND);
00559 
00560   exp_link* curr;   /* Expression list iterator */
00561 
00562   curr = head;
00563   while( (curr != NULL) && (curr->exp->id != id) ) {
00564     curr = curr->next;
00565   }
00566 
00567   PROFILE_END;
00568 
00569   return( curr );
00570 
00571 }

exp_link* exp_link_find_by_pos ( exp_op_type  op,
int  line,
uint32  col,
exp_link head 
)
Returns:
Returns the pointer to the found exp_link or NULL if the search was unsuccessful.

Iteratively searches the exp_link list specified by the head exp_link element. If a matching expression is found, the pointer to this element is returned. If the specified expression could not be matched, the value of NULL is returned.

Parameters:
op Operation
line First line of expression
col First and last column of expression
head Pointer to head of exp_link list to search

References expression_s::all, expression_s::col, exp_link_s::exp, expression_s::line, exp_link_s::next, expression_s::op, PROFILE, and PROFILE_END.

Referenced by funit_db_mod_merge().

00585   { PROFILE(EXP_LINK_FIND_BY_POS);
00586 
00587   exp_link* curr;   /* Expression list iterator */
00588 
00589   curr = head;
00590   while( (curr != NULL) && ((curr->exp->line != line) || (curr->exp->col.all != col) || (curr->exp->op != op)) ) {
00591     curr = curr->next;
00592   }
00593 
00594   PROFILE_END;
00595 
00596   return( curr );
00597 
00598 }

void exp_link_remove ( expression exp,
exp_link **  head,
exp_link **  tail,
bool  recursive 
)

Searches for and removes specified expression link from list.

Searches specified list for expression that matches the specified expression. If a match is found, remove it from the list and deallocate the link memory.

Parameters:
exp Pointer to expression to find and remove
head Pointer to head of expression list
tail Pointer to tail of expression list
recursive If TRUE, recursively removes expression tree and expressions

References exp_link_s::exp, exp_link_remove(), EXPR_LEFT_DEALLOCABLE, EXPR_RIGHT_DEALLOCABLE, expression_dealloc(), free_safe, expression_s::id, expression_s::left, exp_link_s::next, PROFILE, PROFILE_END, expression_s::right, and TRUE.

Referenced by db_remove_statement_from_current_funit(), exp_link_remove(), expression_dealloc(), instance_remove_parms_with_expr(), and mod_parm_find_expr_and_remove().

00838   { PROFILE(EXP_LINK_REMOVE);
00839 
00840   exp_link* curr;  /* Pointer to current expression link */
00841   exp_link* last;  /* Pointer to last expression link */
00842 
00843   assert( exp != NULL );
00844 
00845   /* If recursive mode is set, remove children first */
00846   if( recursive ) {
00847     if( (exp->left != NULL) && EXPR_LEFT_DEALLOCABLE( exp ) ) {
00848       exp_link_remove( exp->left, head, tail, recursive );
00849     }
00850     if( (exp->right != NULL) && EXPR_RIGHT_DEALLOCABLE( exp ) ) {
00851       exp_link_remove( exp->right, head, tail, recursive );
00852     }
00853   }
00854 
00855   curr = *head;
00856   last = NULL;
00857   while( (curr != NULL) && (curr->exp->id != exp->id) ) {
00858     last = curr;
00859     curr = curr->next;
00860     if( curr != NULL ) {
00861       assert( curr->exp != NULL );
00862     }
00863   }
00864 
00865   if( curr != NULL ) {
00866 
00867     if( (curr == *head) && (curr == *tail) ) {
00868       *head = *tail = NULL;
00869     } else if( curr == *head ) {
00870       *head = curr->next;
00871     } else if( curr == *tail ) {
00872       last->next = NULL;
00873       *tail      = last;
00874     } else {
00875       last->next = curr->next;
00876     }
00877 
00878     free_safe( curr, sizeof( exp_link ) );
00879 
00880   }
00881 
00882   /* If recursive flag set, remove expression as well */
00883   if( recursive ) {
00884     expression_dealloc( exp, TRUE );
00885   }
00886 
00887   PROFILE_END;
00888 
00889 }

void fsm_link_add ( fsm table,
fsm_link **  head,
fsm_link **  tail 
)

Adds specified FSM to fsm_link element at the end of the list.

Creates a new fsm_link element with the value specified for table. Sets next pointer of element to NULL, sets the tail element to point to the new element and sets the tail value to the new element.

Parameters:
table Pointer to FSM structure to store
head Pointer to head of FSM list
tail Pointer to tail of FSM list

References malloc_safe, fsm_link_s::next, PROFILE, PROFILE_END, and fsm_link_s::table.

Referenced by fsm_db_read(), fsm_var_add(), and fsm_var_bind_stmt().

00209   { PROFILE(FSM_LINK_ADD);
00210 
00211   fsm_link* tmp;  /* Temporary pointer to newly created fsm_link element */
00212 
00213   tmp = (fsm_link*)malloc_safe( sizeof( fsm_link ) );
00214 
00215   tmp->table = table;
00216   tmp->next  = NULL;
00217 
00218   if( *head == NULL ) {
00219     *head = *tail = tmp;
00220   } else {
00221     (*tail)->next = tmp;
00222     *tail         = tmp;
00223   }
00224 
00225   PROFILE_END;
00226 
00227 }

void fsm_link_delete_list ( fsm_link head  ) 

Deletes entire list specified by head pointer.

Deletes each element of the specified list.

Parameters:
head Pointer to head fsm_link element of list

References free_safe, fsm_dealloc(), fsm_link_s::next, PROFILE, PROFILE_END, and fsm_link_s::table.

Referenced by funit_clean().

01151   { PROFILE(FSM_LINK_DELETE_LIST);
01152 
01153   fsm_link* tmp;  /* Temporary pointer to current link in list */
01154 
01155   while( head != NULL ) {
01156 
01157     tmp  = head;
01158     head = tmp->next;
01159 
01160     /* Deallocate FSM structure */
01161     fsm_dealloc( tmp->table );
01162     tmp->table = NULL;
01163 
01164     /* Deallocate fsm_link element itself */
01165     free_safe( tmp, sizeof( fsm_link ) );
01166 
01167   }
01168 
01169   PROFILE_END;
01170 
01171 }

fsm_link* fsm_link_find ( const char *  name,
fsm_link head 
)

Finds specified FSM structure in fsm_link list.

Returns:
Returns the pointer to the found fsm_link, or NULL if the search was unsuccessful.

Iteratively searches the fsm_link list specified by the head fsm_link element. If a matching FSM is found, the pointer to this element is returned. If the specified FSM structure could not be matched, the value of NULL is returned.

Parameters:
name Name of FSM structure to find
head Pointer to head of fsm_link list to search

References fsm_s::name, fsm_link_s::next, PROFILE, PROFILE_END, and fsm_link_s::table.

Referenced by fsm_arg_parse_attr().

00635   { PROFILE(FSM_LINK_FIND);
00636 
00637   fsm_link* curr;  /* Pointer to current fsm_link element */
00638 
00639   curr = head;
00640   while( (curr != NULL) && (strcmp( curr->table->name, name ) != 0) ) {
00641     curr = curr->next;
00642   }
00643 
00644   PROFILE_END;
00645 
00646   return( curr );
00647 
00648 }

fsm_link* fsm_link_find_by_pos ( int  line,
fsm_link head 
)

Finds specified FSM structure in fsm_link list based on file position.

Returns:
Returns the pointer to the found fsm_link, or NULL if the search was unsuccessful.

Iteratively searches the fsm_link list specified by the head fsm_link element. If a matching FSM is found, the pointer to this element is returned. If the specified FSM structure could not be matched, the value of NULL is returned.

Parameters:
line Line number
head Pointer to head of fsm_link list to search

References fsm_s::line, fsm_link_s::next, PROFILE, PROFILE_END, and fsm_link_s::table.

Referenced by funit_db_mod_merge().

00660   { PROFILE(FSM_LINK_FIND_BY_POS);
00661 
00662   fsm_link* curr;  /* Pointer to current fsm_link element */
00663 
00664   curr = head;
00665   while( (curr != NULL) && (curr->table->line != line) ) {
00666     curr = curr->next;
00667   }
00668 
00669   PROFILE_END;
00670 
00671   return( curr );
00672 
00673 }

void funit_link_add ( func_unit funit,
funit_link **  head,
funit_link **  tail 
)

Adds specified functional unit to funit_link element at the end of the list.

Creates a new funit_link element with the value specified for functional unit. Sets next pointer of element to NULL, sets the tail element to point to the new element and sets the tail value to the new element.

Parameters:
funit Functional unit to add to specified functional unit list
head Pointer to head funit_link element of list
tail Pointer to tail funit_link element of list

References funit_link_s::funit, malloc_safe, funit_link_s::next, PROFILE, and PROFILE_END.

Referenced by db_add_function_task_namedblock(), db_add_instance(), db_read(), and search_init().

00238   { PROFILE(FUNIT_LINK_ADD);
00239         
00240   funit_link* tmp;   /* Temporary pointer to newly created funit_link element */
00241         
00242   tmp = (funit_link*)malloc_safe( sizeof( funit_link ) );
00243         
00244   tmp->funit = funit;
00245   tmp->next  = NULL;
00246         
00247   if( *head == NULL ) {
00248     *head = *tail = tmp;
00249   } else {
00250     (*tail)->next = tmp;
00251     *tail         = tmp;
00252   }
00253 
00254   PROFILE_END;
00255   
00256 }

void funit_link_delete_list ( funit_link **  head,
funit_link **  tail,
bool  rm_funit 
)

Deletes entire list specified by head pointer.

Deletes each element of the specified list.

Parameters:
head Pointer to head funit_link element of list
tail Pointer to tail funit_link element of list
rm_funit If TRUE, deallocates specified functional unit; otherwise, just deallocates the links

References free_safe, funit_link_s::funit, funit_dealloc(), funit_link_s::next, PROFILE, and PROFILE_END.

Referenced by db_close(), and funit_clean().

01180   { PROFILE(FUNIT_LINK_DELETE_LIST);
01181 
01182   funit_link* tmp;   /* Temporary pointer to current link in list */
01183 
01184   while( *head != NULL ) {
01185 
01186     tmp   = *head;
01187     *head = tmp->next;
01188 
01189     /* Deallocate signal */
01190     if( rm_funit ) {
01191       funit_dealloc( tmp->funit );
01192       tmp->funit = NULL;
01193     }
01194 
01195     /* Deallocate funit_link element itself */
01196     free_safe( tmp, sizeof( funit_link ) );
01197 
01198   }
01199 
01200   *tail = NULL;
01201 
01202   PROFILE_END;
01203 
01204 }

void funit_link_display ( funit_link head  ) 

Displays specified functional unit list to standard output.

Displays the string contents of the funit_link list pointed to by head to standard output. This function is mainly used for debugging purposes.

Parameters:
head Pointer to head of funit_link list

References funit_link_s::funit, get_funit_type(), func_unit_s::name, funit_link_s::next, obf_funit, and func_unit_s::type.

00414   {
00415 
00416   funit_link* curr;    /* Pointer to current funit_link link to display */
00417 
00418   printf( "Functional unit list:\n" );
00419 
00420   curr = head;
00421   while( curr != NULL ) {
00422     printf( "  name: %s, type: %s\n", obf_funit( curr->funit->name ), get_funit_type( curr->funit->type ) );
00423     curr = curr->next;
00424   }
00425 
00426 }

funit_link* funit_link_find ( const char *  name,
int  type,
funit_link head 
)

Finds specified functional unit in given funit_link list.

Returns:
Returns the pointer to the found funit_link or NULL if the search was unsuccessful.

Iteratively searches the funit_link list specified by the head funit_link element. If a matching functional unit is found, the pointer to this element is returned. If the specified functional unit could not be matched, the value of NULL is returned.

Parameters:
name Name of functional unit to find
type Type of functional unit to find
head Pointer to head of funit_link list to search

References funit_link_s::funit, func_unit_s::name, funit_link_s::next, PROFILE, PROFILE_END, scope_compare(), and func_unit_s::type.

Referenced by db_add_instance(), db_add_module(), db_read(), fsm_var_add(), fsm_var_bind_expr(), fsm_var_bind_stmt(), and gen_item_resolve().

00686   { PROFILE(FUNIT_LINK_FIND);
00687 
00688   funit_link* curr;    /* Pointer to current funit_link link */
00689 
00690   curr = head;
00691   while( (curr != NULL) && (!scope_compare( curr->funit->name, name ) || (curr->funit->type != type)) ) {
00692     curr = curr->next;
00693   }
00694 
00695   PROFILE_END;
00696 
00697   return( curr );
00698 
00699 }

void funit_link_remove ( func_unit funit,
funit_link **  head,
funit_link **  tail,
bool  rm_funit 
)

Searches for and removes specified functional unit link from list.

Searches for and removes the given functional unit from the given list and adjusts list as necessary.

Parameters:
funit Pointer to functional unit to find and remove
head Pointer to head of functional unit list to remove functional unit from
tail Pointer to tail of functional unit list to remove functional unit from
rm_funit If set to TRUE, deallocates functional unit as well

References free_safe, funit_link_s::funit, funit_dealloc(), funit_link_s::next, PROFILE, and PROFILE_END.

00942   { PROFILE(FUNIT_LINK_REMOVE);
00943 
00944   funit_link* curr = *head;  /* Pointer to current functional unit link */
00945   funit_link* last = NULL;   /* Pointer to last functional unit link traversed */
00946 
00947   assert( funit != NULL );
00948 
00949   /* Search for matching functional unit */
00950   while( (curr != NULL) && (curr->funit != funit) ) {
00951     last = curr;
00952     curr = curr->next;
00953   }
00954 
00955   if( curr != NULL ) {
00956 
00957     /* Remove the functional unit from the list */
00958     if( (curr == *head) && (curr == *tail) ) {
00959       *head = *tail = NULL;
00960     } else if( curr == *head ) {
00961       *head = curr->next;
00962     } else if( curr == *tail ) {
00963       last->next = NULL;
00964       *tail      = last;
00965     } else {
00966       last->next = curr->next;
00967     }
00968 
00969     /* Remove the functional unit, if necessary */
00970     if( rm_funit ) {
00971       funit_dealloc( curr->funit );
00972     }
00973 
00974     /* Deallocate the link */
00975     free_safe( curr, sizeof( funit_link ) );
00976 
00977   }
00978 
00979   PROFILE_END;
00980 
00981 }

void gitem_link_add ( gen_item gi,
gitem_link **  head,
gitem_link **  tail 
)

Adds specified generate item to the end of specified gitem list.

Creates a new gitem_link element with the value specified for generate item. Sets next pointer of element to NULL, sets the tail element to point to the new element and sets the tail value to the new element.

Parameters:
gi Generate item to add to specified gitem_link list
head Pointer to head gitem_link element of list
tail Pointer to tail gitem_link element of list

References gitem_link_s::gi, malloc_safe, gitem_link_s::next, PROFILE, and PROFILE_END.

Referenced by db_add_gen_item_block(), and gen_item_resolve().

00268   { PROFILE(GITEM_LINK_ADD);
00269 
00270   gitem_link* tmp;  /* Temporary pointer to newly created gitem_link element */
00271 
00272   tmp = (gitem_link*)malloc_safe( sizeof( gitem_link ) );
00273 
00274   tmp->gi   = gi;
00275   tmp->next = NULL;
00276 
00277   if( *head == NULL ) {
00278     *head = *tail = tmp;
00279   } else {
00280     (*tail)->next = tmp;
00281     *tail         = tmp;
00282   }
00283 
00284   PROFILE_END;
00285 
00286 }

void gitem_link_delete_list ( gitem_link head,
bool  rm_elems 
)

Deletes entire list specified by head pointer.

Deletes each element of the specified list.

Parameters:
head Pointer to head gitem_link element of list
rm_elems If TRUE, deallocates specified generate item

References free_safe, gen_item_dealloc(), gitem_link_s::gi, gitem_link_s::next, PROFILE, and PROFILE_END.

Referenced by funit_clean(), and instance_dealloc_single().

01213   { PROFILE(GITEM_LINK_DELETE_LIST);
01214 
01215   gitem_link* tmp;  /* Temporary pointer to current link in list */
01216 
01217   while( head != NULL ) {
01218 
01219     tmp  = head;
01220     head = tmp->next;
01221 
01222     /* Deallocate generate item */
01223     gen_item_dealloc( tmp->gi, rm_elems );
01224 
01225     /* Deallocate gitem_link element itself */
01226     free_safe( tmp, sizeof( gitem_link ) );
01227 
01228   }
01229 
01230   PROFILE_END;
01231 
01232 }

void gitem_link_display ( gitem_link head  ) 

Displays specified generate item list to standard output.

Displays the contents of the gitem_link list pointed to by head to standard output. This function is mainly used for debugging purposes.

Parameters:
head Pointer to head of gitem_link list

References gen_item_display_block(), gitem_link_s::gi, and gitem_link_s::next.

00435   {
00436 
00437   gitem_link* curr;  /* Pointer to current gitem_link to display */
00438 
00439   printf( "Generate item list:\n" );
00440 
00441   curr = head;
00442   while( curr != NULL ) {
00443     (void)gen_item_display_block( curr->gi );
00444     curr = curr->next;
00445   }
00446 
00447 }

gitem_link* gitem_link_find ( gen_item gi,
gitem_link head 
)

Finds specified generate item in given gitem_link list.

Returns:
Returns the pointer to the found gitem_link or NULL if the search was unsuccessful.

Iteratively searches the gitem_link list specified by the head gitem_link element. If a matching generate item is found, the pointer to this element is returned. If the specified generate item could not be matched, the value of NULL is returned.

Parameters:
gi Pointer to generate item to find
head Pointer to head of gitem_link list to search

References gen_item_find(), gitem_link_s::gi, gitem_link_s::next, PROFILE, and PROFILE_END.

Referenced by funit_find_signal().

00712   { PROFILE(GITEM_LINK_FIND);
00713 
00714   gitem_link* curr;  /* Pointer to current gitem_link */
00715 
00716   curr = head;
00717   while( (curr != NULL) && (gen_item_find( curr->gi, gi ) == NULL) ) {
00718     curr = curr->next;
00719   }
00720 
00721   PROFILE_END;
00722 
00723   return( curr );
00724 
00725 }

void gitem_link_remove ( gen_item gi,
gitem_link **  head,
gitem_link **  tail 
)

Searches for and removes specified generate item link from list.

Deletes specified generate item from the given list, adjusting the head and tail pointers accordingly.

Parameters:
gi Pointer to specified generate item to remove
head Pointer to head of generate item list
tail Pointer to tail of generate item list

References free_safe, gitem_link_s::gi, gitem_link_s::next, PROFILE, and PROFILE_END.

00900   { PROFILE(GITEM_LINK_REMOVE);
00901 
00902   gitem_link* gil;   /* Pointer to current generate item link */
00903   gitem_link* last;  /* Pointer to last generate item link traversed */
00904 
00905   gil = *head;
00906   while( (gil != NULL) && (gil->gi != gi) ) {
00907     last = gil;
00908     gil  = gil->next;
00909   }
00910 
00911   if( gil != NULL ) {
00912 
00913     if( (gil == *head) && (gil == *tail) ) {
00914       *head = *tail = NULL;
00915     } else if( gil == *head ) {
00916       *head = gil->next;
00917     } else if( gil == *tail ) {
00918       last->next = NULL;
00919       *tail      = last;
00920     } else {
00921       last->next = gil->next;
00922     }
00923 
00924     free_safe( gil, sizeof( gitem_link ) );
00925 
00926   }
00927 
00928   PROFILE_END;
00929 
00930 }

inst_link* inst_link_add ( funit_inst inst,
inst_link **  head,
inst_link **  tail 
)

Adds specified functional unit instance to inst_link element at the end of the list.

Returns:
Returns pointer to newly allocated instance link.

Creates a new inst_link element with the value specified for functional unit instance. Sets next pointer of element to NULL, sets the tail element to point to the new element and sets the tail value to the new element.

Parameters:
inst Functional unit instance root to add
head Pointer to head inst_link element of list
tail Pointer to tail inst_link element of list

References inst_link_s::base, FALSE, inst_link_s::ignore, inst_link_s::inst, malloc_safe, inst_link_s::next, PROFILE, and PROFILE_END.

Referenced by db_add_instance(), db_read(), instance_only_db_merge(), instance_only_db_read(), and search_init().

00300   { PROFILE(INST_LINK_ADD);
00301 
00302   inst_link* tmp;  /* Temporary pointer to newly created inst_link element */
00303 
00304   tmp = (inst_link*)malloc_safe( sizeof( inst_link ) );
00305 
00306   tmp->inst   = inst;
00307   tmp->ignore = FALSE;
00308   tmp->base   = FALSE;
00309   tmp->next   = NULL;
00310 
00311   if( *head == NULL ) {
00312     *head = *tail = tmp;
00313   } else {
00314     (*tail)->next = tmp;
00315     *tail         = tmp;
00316   }
00317 
00318   PROFILE_END;
00319 
00320   return( tmp );
00321 
00322 }

void inst_link_delete_list ( inst_link head  ) 

Deletes entire list specified by head pointer.

Deletes each element of the specified list.

Parameters:
head Pointer to head inst_link element of list

References free_safe, inst_link_s::inst, instance_dealloc(), funit_inst_s::name, inst_link_s::next, PROFILE, and PROFILE_END.

Referenced by db_close().

01240   { PROFILE(INST_LINK_DELETE_LIST);
01241 
01242   inst_link* tmp;  /* Temporary pointer to current link in list */
01243 
01244   while( head != NULL ) {
01245 
01246     tmp  = head;
01247     head = tmp->next;
01248 
01249     /* Deallocate instance item */
01250     instance_dealloc( tmp->inst, tmp->inst->name );
01251 
01252     /* Deallocate inst_link element itself */
01253     free_safe( tmp, sizeof( inst_link ) );
01254 
01255   }
01256 
01257   PROFILE_END;
01258 
01259 }

void inst_link_display ( inst_link head  ) 

Displays specified instance list to standard output.

Displays the contents of the inst_link list pointed to by head to standard output. This function is mainly used for debugging purposes.

Parameters:
head Pointer to head of inst_link list

References inst_link_s::inst, instance_display_tree(), and inst_link_s::next.

Referenced by db_read().

00456   {
00457 
00458   inst_link* curr;  /* Pointer to current inst_link to display */
00459 
00460   printf( "Instance list:\n" );
00461 
00462   curr = head;
00463   while( curr != NULL ) {
00464     instance_display_tree( curr->inst );
00465     curr = curr->next;
00466   }
00467 
00468 }

funit_inst* inst_link_find_by_funit ( const func_unit funit,
inst_link head,
int *  ignore 
)

Finds specified functional unit instance in given inst_link list.

Returns:
Returns the pointer to the found funit_inst or NULL if the search was unsuccessful.

Iteratively searches the inst_link list specified by the head inst_link element. If a matching instance is found, the pointer to this element is returned. If the specified generate item could not be matched, the value of NULL is returned.

Parameters:
funit Functional unit to search for
head Pointer to head of inst_link list to search
ignore Pointer to integer specifying the number of instances to ignore that match the given functional unit

References inst_link_s::inst, instance_find_by_funit(), inst_link_s::next, PROFILE, and PROFILE_END.

Referenced by exclude_is_assert_excluded(), exclude_set_assert_exclude(), expression_resize(), gen_item_resolve(), ovl_collect(), ovl_display_verbose(), ovl_get_coverage(), ovl_get_funit_stats(), race_check_modules(), and scope_find_funit_from_scope().

00765   { PROFILE(INST_LINK_FIND_BY_FUNIT);
00766 
00767   inst_link*  curr;         /* Pointer to current inst_link */
00768   funit_inst* inst = NULL;  /* Pointer to found instance */
00769 
00770   curr = head;
00771   while( (curr != NULL) && ((inst = instance_find_by_funit( curr->inst, funit, ignore )) == NULL) ) {
00772     curr = curr->next;
00773   }
00774 
00775   PROFILE_END;
00776 
00777   return( inst );
00778 
00779 }

funit_inst* inst_link_find_by_scope ( char *  scope,
inst_link head 
)

Finds specified functional unit instance in given inst_link list.

Returns:
Returns the pointer to the found funit_inst or NULL if the search was unsuccessful.

Iteratively searches the inst_link list specified by the head inst_link element. If a matching instance is found, the pointer to this element is returned. If the specified generate item could not be matched, the value of NULL is returned.

Parameters:
scope Hierarchical scope to search for
head Pointer to head of inst_link list to search

References inst_link_s::inst, instance_find_scope(), inst_link_s::next, PROFILE, PROFILE_END, and TRUE.

Referenced by db_read(), db_sync_curr_instance(), instance_only_db_merge(), and instance_only_db_read().

00738   { PROFILE(INST_LINK_FIND_BY_SCOPE);
00739 
00740   inst_link*  curr;         /* Pointer to current inst_link */
00741   funit_inst* inst = NULL;  /* Pointer to found instance */
00742 
00743   curr = head;
00744   while( (curr != NULL) && ((inst = instance_find_scope( curr->inst, scope, TRUE )) == NULL) ) {
00745     curr = curr->next;
00746   }
00747 
00748   PROFILE_END;
00749 
00750   return( inst );
00751 
00752 }

void sig_link_add ( vsignal sig,
sig_link **  head,
sig_link **  tail 
)

Adds specified signal to sig_link element at the end of the list.

Creates a new sig_link element with the value specified for sig. Sets next pointer of element to NULL, sets the tail element to point to the new element and sets the tail value to the new element.

Parameters:
sig Signal to add to specified signal list
head Pointer to head sig_link element of list
tail Pointer to tail sig_link element of list

References malloc_safe, sig_link_s::next, PROFILE, PROFILE_END, and sig_link_s::sig.

Referenced by bind_signal(), db_add_signal(), fsm_gather_signals(), memory_collect(), toggle_collect(), and vsignal_db_read().

00180   { PROFILE(SIG_LINK_ADD);
00181 
00182   sig_link* tmp;   /* Temporary pointer to newly created sig_link element */
00183 
00184   tmp = (sig_link*)malloc_safe( sizeof( sig_link ) );
00185 
00186   tmp->sig  = sig;
00187   tmp->next = NULL;
00188 
00189   if( *head == NULL ) {
00190     *head = *tail = tmp;
00191   } else {
00192     (*tail)->next = tmp;
00193     *tail         = tmp;
00194   }
00195 
00196   PROFILE_END;
00197 
00198 }

void sig_link_delete_list ( sig_link head,
bool  del_sig 
)

Deletes entire list specified by head pointer.

Deletes each element of the specified list.

Parameters:
head Pointer to head sig_link element of list
del_sig If set to TRUE, deallocates the signal; otherwise, leaves signal alone

References free_safe, sig_link_s::next, PROFILE, PROFILE_END, sig_link_s::sig, and vsignal_dealloc().

Referenced by funit_clean().

01122   { PROFILE(SIG_LINK_DELETE_LIST);
01123 
01124   sig_link* tmp;   /* Temporary pointer to current link in list */
01125 
01126   while( head != NULL ) {
01127 
01128     tmp  = head;
01129     head = tmp->next;
01130 
01131     /* Deallocate signal */
01132     if( del_sig ) {
01133       vsignal_dealloc( tmp->sig );
01134       tmp->sig = NULL;
01135     }
01136 
01137     /* Deallocate sig_link element itself */
01138     free_safe( tmp, sizeof( sig_link ) );
01139 
01140   }
01141 
01142   PROFILE_END;
01143 
01144 }

void sig_link_display ( sig_link head  ) 

Displays specified signal list to standard output.

Displays the string contents of the sig_link list pointed to by head to standard output. This function is mainly used for debugging purposes.

Parameters:
head Pointer to head of sig_link list

References vsignal_s::name, sig_link_s::next, obf_sig, and sig_link_s::sig.

00394   {
00395 
00396   sig_link* curr;    /* Pointer to current sig_link link to display */
00397 
00398   printf( "Signal list:\n" );
00399 
00400   curr = head;
00401   while( curr != NULL ) {
00402     printf( "  name: %s\n", obf_sig( curr->sig->name ) );
00403     curr = curr->next;
00404   }
00405 
00406 }

sig_link* sig_link_find ( const char *  name,
sig_link head 
)

Finds specified signal in given sig_link list.

Returns:
Returns the pointer to the found sig_link or NULL if the search was unsuccessful.

Iteratively searches the sig_link list specified by the head sig_link element. If a matching signal is found, the pointer to this element is returned. If the specified signal could not be matched, the value of NULL is returned.

Parameters:
name Name of signal to find
head Pointer to head of sig_link list to search

References vsignal_s::name, sig_link_s::next, PROFILE, PROFILE_END, scope_compare(), and sig_link_s::sig.

Referenced by bind_task_function_namedblock(), covered_create_value_change_cb(), db_add_signal(), db_assign_symbol(), funit_db_mod_merge(), and funit_find_signal().

00610   { PROFILE(SIG_LINK_FIND);
00611 
00612   sig_link* curr;    /* Pointer to current sig_link link */
00613 
00614   curr = head;
00615   while( (curr != NULL) && !scope_compare( curr->sig->name, name ) ) {
00616     curr = curr->next;
00617   }
00618 
00619   PROFILE_END;
00620 
00621   return( curr );
00622 
00623 }

stmt_link* stmt_link_add ( statement stmt,
bool  rm_stmt,
stmt_link **  head,
stmt_link **  tail 
)

Adds specified statement to stmt_link element at the beginning of the list.

Creates a new stmt_link element with the value specified for stmt. Sets next pointer of element to head, sets the head element to point to the new element and (possibly) sets the tail value to the new element.

Parameters:
stmt Pointer to statement to add to specified statement list
rm_stmt Value to specify if statement should be removed when the statement link is deleted
head Pointer to head str_link element of list
tail Pointer to tail str_link element of list

References expression_s::col, statement_s::exp, malloc_safe, stmt_link_s::next, expression_s::part, statement_s::ppline, PROFILE, PROFILE_END, stmt_link_s::rm_stmt, and stmt_link_s::stmt.

Referenced by db_add_statement(), fsm_var_bind_stmt(), statement_db_read(), and stmt_blk_add_to_remove_list().

00094   { PROFILE(STMT_LINK_ADD_HEAD);
00095 
00096   stmt_link* tmp;  /* Temporary pointer to newly created stmt_link element */
00097   stmt_link* curr;
00098 
00099   tmp = (stmt_link*)malloc_safe( sizeof( stmt_link ) );
00100 
00101   tmp->stmt    = stmt;
00102   tmp->rm_stmt = rm_stmt;
00103   tmp->next    = NULL;
00104 
00105   if( *head == NULL ) {
00106 
00107     *head = *tail = tmp;
00108 
00109   } else {
00110 
00111     stmt_link* curr = *head;
00112     stmt_link* last = NULL;
00113 
00114     /* Insert the new statement in order (based on ppline) - start at tail the tail and work to the head */
00115     while( (curr != NULL) &&
00116            ((curr->stmt->ppline < stmt->ppline) ||
00117             ((curr->stmt->ppline == stmt->ppline) &&
00118              (curr->stmt->exp->col.part.first < stmt->exp->col.part.first))) ) {
00119       last = curr;
00120       curr = curr->next;
00121     }
00122 
00123     if( curr == *head ) {
00124       tmp->next = *head;
00125       *head     = tmp;
00126     } else if( curr == NULL ) {
00127       (*tail)->next = tmp;
00128       *tail         = tmp;
00129     } else {
00130       tmp->next  = curr;
00131       last->next = tmp;
00132     }
00133 
00134   }
00135 
00136   PROFILE_END;
00137 
00138   return( tmp );
00139 
00140 }

void stmt_link_delete_list ( stmt_link head  ) 

Deletes entire list specified by head pointer.

Deletes each element of the specified list.

Parameters:
head Pointer to head stmt_link element of list

References free_safe, stmt_link_s::next, PROFILE, PROFILE_END, stmt_link_s::rm_stmt, statement_dealloc(), and stmt_link_s::stmt.

Referenced by funit_clean().

01061   { PROFILE(STMT_LINK_DELETE_LIST);
01062 
01063   stmt_link* curr = head;
01064   stmt_link* tmp;
01065 
01066   while( curr != NULL ) {
01067 
01068     tmp  = curr;
01069     curr = curr->next;
01070 
01071     /* Deallocate statement */
01072     if( tmp->rm_stmt ) {
01073       statement_dealloc( tmp->stmt );
01074     }
01075     tmp->stmt = NULL;
01076 
01077     /* Deallocate stmt_link element itself */
01078     free_safe( tmp, sizeof( stmt_link ) );
01079 
01080   }
01081 
01082   PROFILE_END;
01083 
01084 }

void stmt_link_display ( stmt_link head  ) 

Displays specified statement list to standard output.

Displays the string contents of the stmt_link list pointed to by head to standard output. This function is mainly used for debugging purposes.

Parameters:
head Pointer to head of stmt_link list

References statement_s::exp, expression_s::id, expression_s::line, stmt_link_s::next, statement_s::part, stmt_link_s::stmt, and statement_s::suppl.

00352   {
00353 
00354   stmt_link* curr;   /* Statement list iterator */
00355 
00356   printf( "Statement list:\n" );
00357 
00358   curr = head;
00359   while( curr != NULL ) {
00360     assert( curr->stmt != NULL );
00361     assert( curr->stmt->exp != NULL );
00362     printf( "  id: %d, line: %d, stmt_head: %u\n", curr->stmt->exp->id, curr->stmt->exp->line, curr->stmt->suppl.part.head );
00363     curr = curr->next;
00364   }
00365 
00366 }

stmt_link* stmt_link_find ( int  id,
stmt_link head 
)

Finds specified statement in the given stmt_link list.

Returns:
Returns the pointer to the found stmt_link or NULL if the search was unsuccessful.

Iteratively searches the stmt_link list specified by the head stmt_link element. If a matching statement is found, the pointer to this element is returned. If the specified statement could not be matched, the value of NULL is returned.

Parameters:
id ID of statement to find
head Pointer to head of stmt_link list to search

References statement_s::exp, expression_s::id, stmt_link_s::next, PROFILE, PROFILE_END, and stmt_link_s::stmt.

Referenced by statement_db_read(), and stmt_blk_add_to_remove_list().

00507   { PROFILE(STMT_LINK_FIND);
00508 
00509   stmt_link* curr;   /* Statement list iterator */
00510 
00511   curr = head;
00512   while( (curr != NULL) && (curr->stmt->exp->id != id) ) {
00513     curr = curr->next;
00514   }
00515 
00516   PROFILE_END;
00517 
00518   return( curr );
00519 
00520 }

stmt_link* stmt_link_find_by_pos ( unsigned int  ppline,
uint32  first_col,
stmt_link head 
)

Finds specified statement in the given stmt_link list.

Returns:
Returns the pointer to the found stmt_link or NULL if the search was unsuccessful.

Iteratively searches the stmt_link list specified by the head stmt_link element. If a matching statement is found, the pointer to this element is returned. If the specified statement could not be matched, the value of NULL is returned.

Parameters:
first_col Preprocessor line number of statement to find First column of statement to find
head Pointer to head of stmt_link list to search

References expression_s::col, statement_s::exp, stmt_link_s::next, expression_s::part, statement_s::ppline, PROFILE, PROFILE_END, and stmt_link_s::stmt.

Referenced by funit_db_mod_merge().

00533   { PROFILE(STMT_LINK_FIND_BY_POS);
00534 
00535   stmt_link* curr;   /* Statement list iterator */
00536 
00537   curr = head;
00538   while( (curr != NULL) && ((curr->stmt->ppline != ppline) || (curr->stmt->exp->col.part.first != first_col)) ) {
00539     curr = curr->next;
00540   }
00541 
00542   PROFILE_END;
00543 
00544   return( curr );
00545 
00546 }

void stmt_link_unlink ( statement stmt,
stmt_link **  head,
stmt_link **  tail 
)

Unlinks the stmt_link specified by the specified statement.

Iterates through given statement list searching for the given statement. When the statement link is found that matches, removes that link from the list and repairs the list.

Parameters:
stmt Pointer to the statement to unlink from the given statement list
head Pointer to the head of a statement list
tail Pointer to the tail of a statement list

References free_safe, stmt_link_s::next, PROFILE, PROFILE_END, and stmt_link_s::stmt.

Referenced by db_remove_statement_from_current_funit(), and stmt_blk_remove().

01024   { PROFILE(STMT_LINK_UNLINK);
01025 
01026   stmt_link* curr = *head;
01027   stmt_link* last = NULL;
01028 
01029   while( (curr != NULL) && (curr->stmt != stmt) ) {
01030     last = curr;
01031     curr = curr->next;
01032   }
01033 
01034   if( curr != NULL ) {
01035 
01036     if( (curr == *head) && (curr == *tail) ) {
01037       *head = *tail = NULL;
01038     } else if( curr == *head ) {
01039       *head = (*head)->next;
01040     } else if( curr == *tail ) {
01041       last->next = NULL;
01042       *tail      = last;
01043     } else {
01044       last->next = curr->next;
01045     }
01046 
01047     /* Deallocate the stmt_link */
01048     free_safe( curr, sizeof( stmt_link ) );
01049 
01050   }
01051 
01052   PROFILE_END;
01053 
01054 }

str_link* str_link_add ( char *  str,
str_link **  head,
str_link **  tail 
)

Adds specified string to str_link element at the end of the list.

Returns:
Returns a pointer to newly created string link.

Creates a new str_link element with the value specified for str. Sets next pointer of element to NULL, sets the tail element to point to the new element and sets the tail value to the new element.

Parameters:
str String to add to specified list
head Pointer to head str_link element of list
tail Pointer to tail str_link element of list

References malloc_safe, str_link_s::next, PROFILE, PROFILE_END, str_link_s::range, str_link_s::str, str_link_s::str2, str_link_s::suppl, str_link_s::suppl2, and str_link_s::suppl3.

Referenced by db_add_file_version(), db_add_instance(), directory_load(), exclude_parse_args(), expression_find_rhs_sigs(), merge_parse_args(), merged_cdd_db_read(), ovl_get_coverage(), parse_design(), rank_parse_args(), read_command_file(), score_add_args(), score_parse_args(), search_add_directory_path(), search_add_extensions(), search_add_file(), search_add_include_path(), search_add_no_score_funit(), and sys_task_store_plusarg().

00057   { PROFILE(STR_LINK_ADD);
00058 
00059   str_link* tmp;  /* Temporary pointer to newly created str_link element */
00060 
00061   tmp = (str_link*)malloc_safe( sizeof( str_link ) );
00062 
00063   tmp->str    = str;
00064   tmp->str2   = NULL;
00065   tmp->suppl  = 0x0;
00066   tmp->suppl2 = 0x0;
00067   tmp->suppl3 = 0x0;
00068   tmp->range  = NULL;
00069   tmp->next   = NULL;
00070 
00071   if( *head == NULL ) {
00072     *head = *tail = tmp;
00073   } else {
00074     (*tail)->next = tmp;
00075     *tail         = tmp;
00076   }
00077 
00078   PROFILE_END;
00079 
00080   return( tmp );
00081 
00082 }

void str_link_delete_list ( str_link head  ) 

Deletes entire list specified by head pointer.

Deletes each element of the specified list.

Parameters:
head Pointer to head str_link element of list

References free_safe, str_link_s::next, PROFILE, PROFILE_END, str_link_s::str, and str_link_s::str2.

Referenced by command_exclude(), command_merge(), command_rank(), command_score(), db_close(), db_create_sensitivity_list(), info_dealloc(), merge_parse_args(), rank_parse_args(), read_command_file(), search_free_lists(), and sys_task_dealloc().

00990   { PROFILE(STR_LINK_DELETE_LIST);
00991 
00992   str_link* tmp;   /* Temporary pointer to current link in list */
00993 
00994   while( head != NULL ) {
00995 
00996     tmp  = head;
00997     head = tmp->next;
00998 
00999     /* Deallocate memory for stored string(s) */
01000     free_safe( tmp->str,  (strlen( tmp->str )  + 1) );
01001     free_safe( tmp->str2, (strlen( tmp->str2 ) + 1) );
01002 
01003     tmp->str  = NULL;
01004     tmp->str2 = NULL;
01005 
01006     /* Deallocate str_link element itself */
01007     free_safe( tmp, sizeof( str_link ) );
01008 
01009   }
01010 
01011   PROFILE_END;
01012 
01013 }

void str_link_display ( str_link head  ) 

Displays specified string list to standard output.

Displays the string contents of the str_link list pointed to by head to standard output. This function is mainly used for debugging purposes.

Parameters:
head Pointer to head of str_link list

References str_link_s::next, and str_link_s::str.

00332   {
00333 
00334   str_link* curr;    /* Pointer to current str_link link to display */
00335 
00336   printf( "String list:\n" );
00337 
00338   curr = head;
00339   while( curr != NULL ) {
00340     printf( "  str: %s\n", curr->str );
00341     curr = curr->next;
00342   }
00343 
00344 }

str_link* str_link_find ( const char *  value,
str_link head 
)

Finds specified string in the given str_link list.

Returns:
Returns the pointer to the found str_link or NULL if the search was unsuccessful.

Iteratively searches the str_link list specifed by the head str_link element. If a matching string is found, the pointer to this element is returned. If the specified string could not be matched, the value of NULL is returned.

Parameters:
value String to find in str_link list
head Pointer to head link in str_link list to search

References str_link_s::next, PROFILE, PROFILE_END, and str_link_s::str.

Referenced by db_add_instance(), directory_load(), expression_find_rhs_sigs(), funit_db_write(), merged_cdd_db_read(), parser_check_generation(), race_check_modules(), rank_parse_args(), search_add_file(), and sys_task_test_plusargs().

00482   { PROFILE(STR_LINK_FIND);
00483 
00484   str_link* curr;    /* Pointer to current str_link link */
00485   
00486   curr = head;
00487   while( (curr != NULL) && (strcmp( curr->str, value ) != 0) ) {
00488     curr = curr->next;
00489   }
00490 
00491   PROFILE_END;
00492 
00493   return( curr );
00494 
00495 }

void str_link_remove ( char *  str,
str_link **  head,
str_link **  tail 
)

Searches for and removes specified string link from list.

Searches specified list for string that matches the specified string. If a match is found, remove it from the list and deallocate the link memory.

Parameters:
str Pointer to string to find and remove
head Pointer to head of string list
tail Pointer to tail of string list

References free_safe, str_link_s::next, PROFILE, PROFILE_END, and str_link_s::str.

Referenced by db_end_module().

00791   { PROFILE(STR_LINK_REMOVE);
00792 
00793   str_link* curr;  /* Pointer to current string link */
00794   str_link* last;  /* Pointer to last string link */
00795 
00796   curr = *head;
00797   last = NULL;
00798   while( (curr != NULL) && (strcmp( str, curr->str ) != 0) ) {
00799     last = curr;
00800     curr = curr->next;
00801     assert( (curr == NULL) || (curr->str != NULL) );
00802   }
00803 
00804   if( curr != NULL ) {
00805 
00806     if( (curr == *head) && (curr == *tail) ) {
00807       *head = *tail = NULL;
00808     } else if( curr == *head ) {
00809       *head = curr->next;
00810     } else if( curr == *tail ) {
00811       last->next = NULL;
00812       *tail      = last;
00813     } else {
00814       last->next = curr->next;
00815     }
00816 
00817     /* Deallocate associated string */
00818     free_safe( curr->str, (strlen( curr->str ) + 1) );
00819 
00820     /* Now deallocate this link itself */
00821     free_safe( curr, sizeof( str_link ) );
00822 
00823   }
00824 
00825   PROFILE_END;
00826 
00827 }

Generated on Sun Nov 21 00:55:39 2010 for Covered by  doxygen 1.6.3