Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (AndrewAMD, monk12, TipmyPip, Quad, aliswee), 1,031 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: baffling crash [Re: irchel2] #430903
10/04/13 18:45
10/04/13 18:45
Joined: Dec 2008
Posts: 1,218
Germany
Rackscha Offline
Serious User
Rackscha  Offline
Serious User

Joined: Dec 2008
Posts: 1,218
Germany
Please keep in mind that the 64kb limitation is a limitation of Lite-C. Other Compilers set the limit to 1MB.(i.e. Delphi, and i am sure other C and C++ compilers do the same)

Last edited by Rackscha; 10/04/13 18:45.

MY Website with news of my projects:
(for example my current
Muliplayer Bomberman,
GenesisPrecompiler for LiteC
and TileMaster, an easy to use Tile editor)
Sparetime-Development

Re: baffling crash [Re: irchel2] #430904
10/04/13 19:19
10/04/13 19:19
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: irchel2
I'd give malloc() a shot. It allocates memory on the heap instead of the stack. Look up a C language documentation how to use it.
Don't use malloc. Use sys_malloc in lite-c as I suggested above.
Originally Posted By: irchel2
You would have to use int instead of var then, I presume.
The type of the variable is totally irrelevant for sys_malloc / malloc.


Always learn from history, to be sure you make the same mistakes again...
Re: baffling crash [Re: Uhrwerk] #430914
10/05/13 08:00
10/05/13 08:00
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
As I've written in my post above it does not crash immediately, at least it did not in my case. Over a couple of years every now and then I tried a different puzzle solving algorithm (for the puzzle "Eternity II"), for instance one that would trace the board in a spiral:



The recursive structure of my first algorithm used a function as follows:

void solve_step(...)
{
var tile_array[1024];
var used[256];
...
}

It seemed to worked flawlessly until a good number of pieces had been placed but then it would just go into a wrong direction for a couple of pieces (for no apparent reason) before crashing.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: baffling crash [Re: Superku] #430915
10/05/13 08:54
10/05/13 08:54
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
I know it's not on topic in the purest form of on-topicness, but the way this is usually solved, is by changing your algorithm so that it uses a loop instead of recursion. Granted, that isn't always possible, in which case you have to fallback to recursion and allocation on the heap.

The first solution works great when you have only values that are further used when you go down the rabbit hole, like in this classic example for recursion:
Code:
int factorial(int n)
{
    if(!n)
        return 1;
    
    return n * factorial(n - 1);
}



Using a sophisticated compiler, you will end up with no recursion at all since your function would become victim of tail-call optimization. However, it's trivial to rewrite this using a loop:

Code:
int factorial(int n)
{
    int fact = 1;
    
    for(; n >= 1; n --)
        fact *= n;
        
    return fact;
}



Granted, for the sake of it I chose a really trivial example. But you should get the gist of it. Also take the following away: The stack isn't meant to hold huge allocations. Don't use it for that. Everything bigger than a hundred bytes probably belong better on the heap (there are exceptions, but yeah, rule of thumbs).


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Page 2 of 2 1 2

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

Gamestudio download | chip programmers | 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