From: "Alphex K." <alphex@crew.org.ru>
Cc: linux-c-programming@vger.kernel.org
Subject: Some troubles with linked list/tree
Date: Thu, 29 Apr 2004 19:39:34 +0400 [thread overview]
Message-ID: <20040429193934.18faf8e1.alphex@crew.org.ru> (raw)
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
next reply other threads:[~2004-04-29 15:39 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2004-04-29 15:39 Alphex K. [this message] 2004-04-30 4:25 ` Some troubles with linked list/tree 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040429193934.18faf8e1.alphex@crew.org.ru \
--to=alphex@crew.org.ru \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).