Example #1
0
/* Function:  free_Gene(obj)
 *
 * Descrip:    Free Function: removes the memory held by obj
 *             Will chain up to owned members and clear all lists
 *
 *
 * Arg:        obj [UNKN ] Object that is free'd [Gene *]
 *
 * Return [UNKN ]  Undocumented return value [Gene *]
 *
 */
Gene * free_Gene(Gene * obj) 
{
    int i;   


    if( obj == NULL) {  
      warn("Attempting to free a NULL pointer to a Gene obj. Should be trappable");  
      return NULL;   
      }  


    if( obj->dynamite_hard_link > 1)     {  
      obj->dynamite_hard_link--; 
      return NULL;   
      }  
    /* obj->parent is linked in */ 
    if( obj->genomic != NULL)    
      free_Genomic(obj->genomic);    
    if( obj->transcript != NULL) {  
      for(i=0;i<obj->len;i++)    {  
        if( obj->transcript[i] != NULL)  
          free_Transcript(obj->transcript[i]);   
        }  
      ckfree(obj->transcript);   
      }  
    if( obj->name != NULL)   
      ckfree(obj->name);     
    if( obj->seqname != NULL)    
      ckfree(obj->seqname);  


    ckfree(obj); 
    return NULL; 
}    
Example #2
0
/* Function:  flush_Gene(obj)
 *
 * Descrip:    Frees the list elements, sets length to 0
 *             If you want to save some elements, use hard_link_xxx
 *             to protect them from being actually destroyed in the free
 *
 *
 * Arg:        obj [UNKN ] Object which contains the list  [Gene *]
 *
 * Return [UNKN ]  Undocumented return value [int]
 *
 */
int flush_Gene(Gene * obj) 
{
    int i;   


    for(i=0;i<obj->len;i++)  { /*for i over list length*/ 
      if( obj->transcript[i] != NULL)    {  
        free_Transcript(obj->transcript[i]); 
        obj->transcript[i] = NULL;   
        }  
      } /* end of for i over list length */ 


    obj->len = 0;    
    return i;    
}    
Example #3
0
/* Function:  free_Gene(obj)
 *
 * Descrip:    Free Function: removes the memory held by obj
 *             Will chain up to owned members and clear all lists
 *
 *
 * Arg:        obj [UNKN ] Object that is free'd [Gene *]
 *
 * Return [UNKN ]  Undocumented return value [Gene *]
 *
 */
Gene * free_Gene(Gene * obj) 
{
    int return_early = 0;    
    int i;   


    if( obj == NULL) {  
      warn("Attempting to free a NULL pointer to a Gene obj. Should be trappable");  
      return NULL;   
      }  


#ifdef PTHREAD   
    assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); 
#endif   
    if( obj->dynamite_hard_link > 1)     {  
      return_early = 1;  
      obj->dynamite_hard_link--; 
      }  
#ifdef PTHREAD   
    assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0);   
#endif   
    if( return_early == 1)   
      return NULL;   
    /* obj->parent is linked in */ 
    if( obj->genomic != NULL)    
      free_Genomic(obj->genomic);    
    if( obj->transcript != NULL) {  
      for(i=0;i<obj->len;i++)    {  
        if( obj->transcript[i] != NULL)  
          free_Transcript(obj->transcript[i]);   
        }  
      ckfree(obj->transcript);   
      }  
    if( obj->name != NULL)   
      ckfree(obj->name);     
    if( obj->seqname != NULL)    
      ckfree(obj->seqname);  


    ckfree(obj); 
    return NULL; 
}