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
2 registered members (TipmyPip, 1 invisible), 18,758 guests, and 8 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 1 of 3 1 2 3
Script Crash loves me :( #411606
11/18/12 05:54
11/18/12 05:54
Joined: Nov 2011
Posts: 139
India
Yashas Offline OP
Member
Yashas  Offline OP
Member

Joined: Nov 2011
Posts: 139
India
Code:
typedef struct Applet 
{
	STRING * Name;
	STRING * Author;
	STRING * Version;
	STRING * Description;
	
	PANEL * Container;
	void * Initilize;
	void * Deinitlize;
	int init;
}Applet;
typedef struct AppletList
{
	Applet * applet;
	Applet * next;
	Applet * previous;	
}AppletList;
AppletList * Applets = sys_malloc(sizeof(AppletList));


Code:
void RegisterApplet(Applet * applet)
{
	if(!applet) { return error("RegisterApplet:Invalid Applet"); }
	AppletList * Temp = Applets;
	AppletList * Current = sys_malloc(sizeof(AppletList));
	Current->applet = applet;
	while(1)
	{
		if(Temp->next) 
		{
			Temp = Temp->next;	
		}
		else if(Temp->next == NULL)
		{
			Current->previous = Temp;
			Current->next = NULL;
			Temp->next = Current;
			break;
		}
	}  
	return 0; 
}


Code:
void main ()
{
	clock = CreateApplet("Clock","Yashas Samaga","1.0","ABC",CLock,ClockInitilizer,DeinitCLock);	
	RegisterApplet(clock);
}


frown A Script Crash in RegisterApplet


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

Joined: Apr 2007
Posts: 3,751
Canada
You only back Applets with memory, but the structs content remain uninitialized and might very well be something else than NULL. Also, you probably want to build your linked list different using a more common approach like:

Code:
typedef struct Applet 
{
	STRING *Name;
	STRING *Author;
	STRING *Version;
	STRING *Description;
	
	PANEL *Container;
	void *Initilize;
	void *Deinitlize;
	int init;
	
	struct Applet *next;
	struct Applet *prev;
} Applet;

Applet *listHead = NULL;
Applet *listTail = NULL;

void RegisterApplet(Applet *applet)
{
    if(listHead)
    {
        applet->next = NULL;
        applet->prev = listTaile;
        
        listTail->next = applet;
        listTail = applet;
    }
    else
    {
        applet->next = applet->prev = NULL;
    
        listTail = applet;
        listHead = applet;
    }
}


Last edited by JustSid; 11/18/12 06:38. Reason: Forgot a pointer

Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: Script Crash loves me :( [Re: WretchedSid] #411618
11/18/12 11:05
11/18/12 11:05
Joined: Sep 2009
Posts: 1,032
Budapest
Aku_Aku Offline
Serious User
Aku_Aku  Offline
Serious User

Joined: Sep 2009
Posts: 1,032
Budapest
You must be an astronomer with a big, good telescope, to see from Germany what happened on a tiny screen in India, and so lucky to catch that moment when the message appeared on the screen. cool

Re: Script Crash loves me :( [Re: WretchedSid] #411626
11/18/12 12:20
11/18/12 12:20
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Originally Posted By: JustSid
...but the structs content remain uninitialized and might very well be something else than NULL.

How should that happen?


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

Joined: Apr 2007
Posts: 3,751
Canada
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?


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: Script Crash loves me :( [Re: WretchedSid] #411630
11/18/12 13:14
11/18/12 13:14
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
sys_malloc zeros the allocated memory (afaik)


Visit my site: www.masterq32.de
Re: Script Crash loves me :( [Re: MasterQ32] #411631
11/18/12 13:21
11/18/12 13:21
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
It sure does.
Originally Posted By: Manual
Returns:
void* pointer to the allocated memory area, or NULL when the allocation failed. The area is cleared to zero at allocation.


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

Joined: Apr 2007
Posts: 3,751
Canada
Well, this is awkward... I'll just slowly walk away now an... GUYS, LOOK, OVER THERE, A CUTE BUNNY *flies away*


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: Script Crash loves me :( [Re: WretchedSid] #411741
11/19/12 13:25
11/19/12 13:25
Joined: Mar 2006
Posts: 1,993
Karlsruhe
PadMalcom Offline
Serious User
PadMalcom  Offline
Serious User

Joined: Mar 2006
Posts: 1,993
Karlsruhe
Haha but malloc doesn't! I guess this is one of the specials of sys_malloc.

Re: Script Crash loves me :( [Re: PadMalcom] #411755
11/19/12 15:20
11/19/12 15:20
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Where is that bunny? Where? *jumps up and down* Where? Did I miss it? Was it cute? OMG. I haven't seen it. :-(


Always learn from history, to be sure you make the same mistakes again...
Page 1 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