Code:
long slab;         [allocates a single LONG in memory] Correct!
long slab[4];      [allocates four countiguous LONGs in memory]Correct!

long* slab[4];     [allocates four countiguous pointers in memory to other LONGs]Wrong! see below

ENTITY* slab[4];   [allocates four countiguous pointers in memory to ENTITYs] Wrong! see below

ENTITY* *slab[4];  [allocates four countiguous pointers in memory to an 
                      array of ENTITY pointers (ie ENTITY**)                ]Wrong! see below.



I think I got your misunderstanding now. Ok, you first example was "long slab;" which in fact used 8 bytes of memory. Now why is it using 8 bytes? Because that's the size of a long variable. So far so good. "long slab[4]" will allocate 8 * 4 = 32 bytes. Why? Because one long needs 8 bytes and you need space for four of them. Now to the examples below which work all the same way. In "long* slab[4];" you declare a pointer (!!) to some longs. This will require 4 bytes of memory, because that's the size of a pointer. The compiler does not care about the fact, that the pointer should point to an array of four longs. It just sees that you're declaring a pointer and that's it for memory consumption - 4 bytes. The rest of the declaration is just used by the static type system.

Until now your example is a 32 bit pointer pointing to mount doom. So you better initialize it like "long* slab[4] = NULL;". This will show you and other programmers it's not pointing to anywhere at the moment. If you want to use your pointer to the array you have to allocate memory for it. "long* slab[4] = sys_malloc(4 * 8);" Not doing this will result in overwriting random memory or reading from random memory when accessing the variable.


Always learn from history, to be sure you make the same mistakes again...