codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  I have a trouble when i use the struct list  johnvn at 06:38 on Sunday, May 22, 2005
 

My program use a list like that :

//**************************************************
struct NODE
{
int mt[3][3];
int h, g, f;
NODE *Next;
};
struct List
{
NODE *Head;
NODE *Tail;
};

//****************And i get a new Node :

NODE GetNode(int A[3][3], int h, int g)
{
NODE *p=new NODE;
if (!p)
{
cout<<"Cannot create a new node";
return NULL;
}
// get the value for NODE
..........
//
p->h=h;
p->g=g;
p->f=g+h;
p->Next=NULL;
return p;
}

//************Then Insert a node after List like that :
NODE *InsertTail(List &LS, int A[3][3], int h, int g)
{
NODE *new_node = GetNode(A,h,g);
if (!new_node)
return NULL;
if (!LS.Head) //List is Empty
{
LS.Head=new_node;
LS.Head=LS.Tail;
}
else
{
LS.Tail->Next=new_node;
LS.Tail=new_node;
}
return new_node;
}

//******Let the List Empty:
void EmptyList(List &LS)
{
LS.Head=LS.Tail=NULL;
}

//*************************************************************

In my program, i have some functions that remove an element of the list and add a new element to the tail....
But if i can't InsertTail for the large times (about over 300 times). Why is it? I think After finished my GetNode or InsertTail function, the variable Node that i create with "new" keyword must be detroyed automatically right?
I really dont know about it.
Because after i use InsertTail, i remove alot of elements in it.
And my List never has more than 9 elements. Why my memory is full? (I receive the message : "cannot create a new node" that i type in the GetNode function )
How can i solve my problem with the large loop to use
InsertTail.
Please help me.
Thanks
John









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  Re: Problem with concatenation
•  how to genrates the crystal report by sending a id at runtime
•  help me
•  pls help me with this..
•  Re: Security - Code verify
•  Job @ EarlySail
•  Job @ EarlySail (perl)
•  IPC problem
•  Re: import contacts of msn/yahoo


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2007