But unfortunately your snippet doesnt work well with size of ARRAYS of objects.

But regardless of that... ITS WORKING!!! And the way I wanted it to also!
In the spoiler below is a cut & paste straight from my project.

It turns out that it was a simple sloppiness in my bracket usage that was screwing
me up and causing an array overflow, into some other space.

If you look in the spoiler, in the "create_entities" function you will NOW find
Code:
sys_malloc(sizeof(ENTITY*)*(LOD_count[LOD]+1))

My problem was was that I left out an important pair of brackets near the end...
Code:
sys_malloc(sizeof(ENTITY*)*LOD_count[LOD]+1)

Look carefully! And you will see when I filled the last element of the array
it would overflow the end of the malloc'ed area by three bytes!

Im not sure WHAT it was overflowing INTO, but it was obviously critical!

So before I say "nyha nyha, I was right and you were wrong!!", I will say that
this is still only a VERY small testbed project for proof-of-concept testing.
So there is not much 'happening' in it yet. So as more functionality of the
concept under test goes in, it may yet prove you right over me.
(in regards to how the engine handles declares like "ENTITY** slab[4];" that is)

Click to reveal..
Code:
ENTITY** slab_ents[4];		//slab_ent store of EACH LOD entities		(index = LOD number)


void create_entities()
{
	...
	// Create Entities in Appropriate slab_ents STORE
	cnt=0;	for(LOD=0; LOD<4; LOD++)
	{	
		(slab_ents[LOD]) = (ENTITY**)sys_malloc(sizeof(ENTITY*)*(LOD_count[LOD]+1));
		for(i=0; i<LOD_count[LOD]; i++)
		{	
			(slab_ents[LOD])[i] = ent_create(LOD_names[LOD], S_PARK, NULL);
			set((slab_ents[LOD])[i], INVISIBLE);	ent_clone((slab_ents[LOD])[i]);
		}	
		(slab_ents[LOD])[i] = NULL;
	}			
}


void slabs_terminate()
{	
	var LOD, i;		
	for(LOD=0; LOD<4; LOD++)	
	{	
		i=-1;	
		while((slab_ents[LOD])[i++])
		{	ent_remove((slab_ents[LOD])[i]);		}
		sys_free(slab_ents[LOD]);
	}
}


Thanks for the help dude. You made me think in "unusual" ways and so I was
able to find the problem while I was in there...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial