model_server/xref/src/xrefSymbol.h.cxx
// need to search thru ALL xrefs to update this symbol ? probably not
// return the new xrefSymbol
need to search thru ALL xrefs to update this symbol . probably not
return the new xrefSymbol
need to search thru ALL xrefs to update this symbol . probably not return the new xrefSymbol
xrefSymbol* xrefSymbol::update_name_priv(char const *new_name)
{
  Initialize(xrefSymbol::update_name_priv);
  Xref* xr = get_Xref();
  XrefTable *xref = xr->get_lxref();
  if ((xref->my_Xref && xref->my_Xref->get_home_flag() == 0) ) return 0;
  IF (!xref->sym_is_writable) return 0;
  int h = xref->Mhash(this->get_name(xref)) % ntohl(xref->get_header()->table_max);
  hashElmt* hel = xref->table[h];
  if (hel== 0) return NULL;
  do {
    xrefSymbol * sym = hel->el;
    if (sym == this) {
      sym->set_hash_value(xref->Mhash(new_name));
      uint new_name_l = strlen(new_name);
      uint sym_name_offset = xref->update_sym_addr_offset(new_name_l+1);
      xref->insert_xrefSymbol_name(sym_name_offset, new_name, new_name_l);
      sym->set_name_offset(sym_name_offset);
      int ind = ntohl(sym->get_hash_value()) % ntohl(xref->get_header()->table_max);
      if (hel->prev) {
	hel->prev->next = hel->next;
	if (hel->next)
	  hel->next->prev = hel->prev;
      }
      else {
	if (hel->next)
	  hel->next->prev = NULL;
	xref->table[h] = hel->next;
      }
      if (xref->table[ind])
	xref->table[ind]->prev = hel;
      hel->next = xref->table[ind];
      hel->prev = NULL;
      xref->table[ind] = hel;
      if (!SharedXref::saving()) {
        xref_notifier_report(0, this);
      }
      return this;
    }
  } while (hel = hel->next);
  return NULL; 
}
xrefSymbol * xrefSymbol :: update_name_priv ( char const * new_name ) { Initialize ( xrefSymbol :: update_name_priv ) ; Xref * xr = get_Xref ( ) ; XrefTable * xref = xr -> get_lxref ( ) ; if ( ( xref -> my_Xref && xref -> my_Xref -> get_home_flag ( ) == 0 ) ) return 0 ; IF ( ! xref -> sym_is_writable ) return 0 ; int h = xref -> Mhash ( this -> get_name ( xref ) ) % ntohl ( xref -> get_header ( ) -> table_max ) ; hashElmt * hel = xref -> table [ h ] ; if ( hel == 0 ) return NULL ; do { xrefSymbol * sym = hel -> el ; if ( sym == this ) { sym -> set_hash_value ( xref -> Mhash ( new_name ) ) ; uint new_name_l = strlen ( new_name ) ; uint sym_name_offset = xref -> update_sym_addr_offset ( new_name_l + 1 ) ; xref -> insert_xrefSymbol_name ( sym_name_offset , new_name , new_name_l ) ; sym -> set_name_offset ( sym_name_offset ) ; int ind = ntohl ( sym -> get_hash_value ( ) ) % ntohl ( xref -> get_header ( ) -> table_max ) ; if ( hel -> prev ) { hel -> prev -> next = hel -> next ; if ( hel -> next ) hel -> next -> prev = hel -> prev ; } else { if ( hel -> next ) hel -> next -> prev = NULL ; xref -> table [ h ] = hel -> next ; } if ( xref -> table [ ind ] ) xref -> table [ ind ] -> prev = hel ; hel -> next = xref -> table [ ind ] ; hel -> prev = NULL ; xref -> table [ ind ] = hel ; if ( ! SharedXref :: saving ( ) ) { xref_notifier_report ( 0 , this ) ; } return this ; } } while ( hel = hel -> next ) ; return NULL ; }
need to search thru ALL xrefs to update this symbol ?
need to search thru ALL xrefs to update this symbol ?
// notify, but not during a save operation!!!!!! // should be internal err message