linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Some troubles with linked list/tree
@ 2004-04-29 15:39 Alphex K.
  2004-04-30  4:25 ` Glynn Clements
  0 siblings, 1 reply; 6+ messages in thread
From: Alphex K. @ 2004-04-29 15:39 UTC (permalink / raw)
  Cc: linux-c-programming

Hi guys!
I'm have a one question
so I'm have a two linked lists
typedef struct                                                                  
{                                                                               
   int id;                                                                      
   int sf_id;                                                                   
   char *from_date;                                                             
   char *to_date;                                                               
   struct SfList *next;                                                         
} SfList;

typedef struct                                                                  
{                                                                               
   int id;                                                                      
   char *name;                                                                  
   char *author;                                                                
   char *note;                                                                  
   int cl_id;                                                                   
   SfList * list;                                                               
   struct OapAdvAction *next;                                                   
} OapAdvAction;

so and functions to operate with there
SfList * AddSfEntry(SfList * list,int sf_id,char *from_date,char *to_date)           
{                                                                                    
   int id=0;                                                                         
   SfList * lp=list;                                                                 
   if(list!=NULL)                                                                    
     {                                                                               
        id=1;                                                                        
        while(list->next!=NULL)                                                      
          {                                                                          
             list=list->next;                                                        
             id++;                                                                   
          }                                                                          
        list->next=(struct SfList  *) malloc(sizeof(SfList));                        
        list=list->next;                                                             
        list->next=NULL;                                                             
        list->id=id;                                                                 
        list->sf_id=sf_id;                                                           
        list->from_date=from_date;                                                   
        list->to_date=to_date;                                                       
        return lp;                                                                   
     }                                                                               
   else                                                                              
     {                                                                               
        list=(struct SfList  *) malloc(sizeof(SfList));                              
        list->next=NULL;                                                             
        list->id=id;                                                                 
        list->sf_id=sf_id;                                                           
        list->from_date=from_date;                                                   
        list->to_date=to_date;                                                       
        return list;                                                                 
     }                                                                               
   // end ;-)                                                                        
}

and for OapAdvAction structure
OapAdvAction * AddAdvAction(OapAdvAction * action,char *name,char *author,           
                            char *note,int cl_id,SfList * list)                      
{                                                                                    
   OapAdvAction * lp=action;                                                         
   int id=0;                                                                         
   if(action!=NULL)                                                                  
     {                                                                               
        id=1;                                                                        
        while(action->next!=NULL)                                                    
          {                                                                          
             action=action->next;                                                    
             id++;                                                                   
          }                                                                          
        action->next=(struct OapAdvAction  *) malloc(sizeof(OapAdvAction)+sizeof(SfL$
        action=action->next;                                                         
        action->next=NULL;                                                           
        action->id=id;                                                               
        action->name=name;                                                           
        action->author=author;                                                       
        action->note=note;                                                           
        action->cl_id=cl_id;                                                         
        // adding list                                                               
        /*while(list!=NULL)                                                          
          {                                                                          
             action->list=AddSfEntry(action->list,list->sf_id,list->from_date,       
                                     list->to_date);                                 
             list=list->next;                                                        
          }*/                                                                        
        action->list=(struct SfList  *) malloc(sizeof(list));                        
        action->list=list;                                                           
        return lp;                                                                   
     }                                                                               
   else                                                                              
     {                                                                               
        action=(struct OapAdvAction  *) malloc(sizeof(OapAdvAction)+sizeof(SfList)); 
        action->next=NULL;                                                           
        action->id=id;                                                               
        action->name=name;                                                           
        action->author=author;                                                       
        action->note=note;                                                           
        action->cl_id=cl_id;                                                         
        // adding list                                                               
        /*while(list!=NULL)                                                          
          {                                                                          
             action->list=AddSfEntry(action->list,list->sf_id,list->from_date,       
                                     list->to_date);                                 
             list=list->next;                                                        
          }*/                                                                        
        action->list=(struct SfList  *) malloc(sizeof(list));                        
        action->list=list;                                                           
        return action;
}
}

what the right way to add SfList to OapAdvAction ?
I try some methods but it doesn't work?

Thanx

---===---
Alphex Kaanoken
Senior developer of Crew IT research labs
web: http://crew.org.ru
mailto:Alphex@Crew.Org.RU

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-04-30 18:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-04-29 15:39 Some troubles with linked list/tree Alphex K.
2004-04-30  4:25 ` Glynn Clements
2004-04-30  9:15   ` Alphex K.
2004-04-30 13:38     ` Glynn Clements
2004-04-30 15:18       ` Alphex K.
2004-04-30 18:38         ` Glynn Clements

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).