Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (Ayumi, NewbieZorro, TipmyPip), 13,888 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 3 1 2 3
Re: Script Crash loves me :( [Re: WretchedSid] #411759
11/19/12 15:34
11/19/12 15:34
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline
Expert
Helghast  Offline
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
Originally Posted By: JustSid
Originally Posted By: Uhrwerk
Originally Posted By: JustSid
...but the structs content remain uninitialized and might very well be something else than NULL.

How should that happen?

By sys_malloc() not zeroing the allocated memory?


malloc doesnt, sys_malloc does wink


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
Re: Script Crash loves me :( [Re: Uhrwerk] #411762
11/19/12 15:55
11/19/12 15:55
Joined: Apr 2005
Posts: 4,506
Germany
F
fogman Offline
Expert
fogman  Offline
Expert
F

Joined: Apr 2005
Posts: 4,506
Germany
Originally Posted By: Uhrwerk
Where is that bunny? Where? *jumps up and down* Where? Did I miss it? Was it cute? OMG. I haven't seen it. :-(




no science involved
Re: Script Crash loves me :( [Re: Uhrwerk] #411844
11/20/12 12:21
11/20/12 12:21
Joined: Nov 2011
Posts: 139
India
Yashas Offline OP
Member
Yashas  Offline OP
Member

Joined: Nov 2011
Posts: 139
India
Code:
if(Temp->next) 
{
	Temp = Temp->next;	
}


It's exactly same as the code that I have given at the start of this post.
Just found wheres the crash, I want to fix it not new ways laugh

Last edited by Yashas; 11/20/12 12:25. Reason: Forgot to close code tag :D

Keep smiling laugh
http://translation.babylon.com/ - Translate many languages
Re: Script Crash loves me :( [Re: Uhrwerk] #411928
11/21/12 11:08
11/21/12 11:08
Joined: Nov 2011
Posts: 139
India
Yashas Offline OP
Member
Yashas  Offline OP
Member

Joined: Nov 2011
Posts: 139
India
Can anyone give me some code for Unregistering a element from the linked list given JustSid.


This was what I had done for my linked list.Now I am following what JustSid code does laugh
Code:
int UnregisterApplet(Applet * applet)
{
	if(!applet) { return error("RegisterApplet:Invalid Applet"); }
	AppletList * Temp = Applets;
	while(1)
	{
		if(!Temp->next) 
		{ 
			return error("UnregisterApplet:Could not find the spcified Applet");
			break;
		}
		
		if(Temp->applet == applet) 
		{
			AppletList * Temp2 = Temp->previous;
			Temp2->next = Temp->next;
			Temp2 = Temp->next;
			Temp2->previous = Temp->previous;
			return 0;
		}
		else
		{
			Temp = Temp->next;	
		}
	}  
}



Thanks


Keep smiling laugh
http://translation.babylon.com/ - Translate many languages
Re: Script Crash loves me :( [Re: Yashas] #411930
11/21/12 11:31
11/21/12 11:31
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
There you go:

Code:
void UnregisterApplet(Applet *applet)
{
    if(applet->prev)
        applet->prev->next = applet->next;
    
    if(applet->next)
        applet->next->prev = applet->prev;
        
    if(applet == listHead)
        listHead = applet->next;
        
    if(applet == listTail)
        listTail = applet->prev;
}



Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: Script Crash loves me :( [Re: WretchedSid] #411933
11/21/12 11:56
11/21/12 11:56
Joined: Nov 2011
Posts: 139
India
Yashas Offline OP
Member
Yashas  Offline OP
Member

Joined: Nov 2011
Posts: 139
India
How do I get number of elements??(I hav planned to keep moving to next pointer till a get a NULL) Any other efficient way??

And the listHead is the first element of the linked list right??
and listTail,the last??

Thanks

Last edited by Yashas; 11/21/12 12:01. Reason: Made it clear

Keep smiling laugh
http://translation.babylon.com/ - Translate many languages
Re: Script Crash loves me :( [Re: Yashas] #411941
11/21/12 12:54
11/21/12 12:54
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
No, that is the most efficient way to calculate it. The only alternative is caching the value, i.e. incrementing a var every time something is added to the list and decrementing it whenever something gets removed.


Always learn from history, to be sure you make the same mistakes again...
Re: Script Crash loves me :( [Re: Uhrwerk] #411943
11/21/12 13:16
11/21/12 13:16
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Originally Posted By: Uhrwerk
The only alternative is caching the value

Which might not be a bad idea after all. Generally speaking it's better to wrap the linked list into some kind of container which abstracts the process of adding and removing references to the list so you don't have to implement it over and over again every time you need a linked list (and the container can also keep track of the number of nodes).
I have posted a fairly basic example of such a linked list here: http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=408638#Post408638


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: Script Crash loves me :( [Re: WretchedSid] #411968
11/21/12 15:29
11/21/12 15:29
Joined: Nov 2011
Posts: 139
India
Yashas Offline OP
Member
Yashas  Offline OP
Member

Joined: Nov 2011
Posts: 139
India
And here is there any efficient way to fetch an element somewhere in the middle of linked list??

What I did is a big loop which wud keep *next until the element is reached.

What I am trying is I take a number from the button onClick event and go finding the element with the same number.


Keep smiling laugh
http://translation.babylon.com/ - Translate many languages
Re: Script Crash loves me :( [Re: Yashas] #411969
11/21/12 15:37
11/21/12 15:37
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Time to search elements in a linked list is linear. You cannot change that until you back the linked list by another data structure or use a completely different one, e.g. a hashmap.

You shouldn't bother about this anyways, as long as you don't have a sever speed problem.


Always learn from history, to be sure you make the same mistakes again...
Page 2 of 3 1 2 3

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1