Hi!

I'm assuming you're working in userspace, since the memory allocation
function in the kernel is kmalloc.

On Sat, 2007-09-29 at 16:49 -0700, Irfan Ahmed wrote:
> I need four dimensional array like 
> double a[256][256][256][256];
> 
> 
> but the size is too big to use an array.

That's 32 GB memory! Are you *really* sure you want to do this? It would
require a 64 bit system and "some" ram/swap space if you access the
array. You have to do this on the *heap* not on the stack and have to be
careful not to produce an integer overflow.

> If I use only pointer like
> double ****a;
> 
> to allocate this memory, I have to run 3 loops to allocate
> memory ..which takes lots of time.

Because of 256^3 = ~17 million system calls...

> I was thinking to use *a[256][256][256]
> Can I use this ...and if yes how I can allocate the memory for
> this...?

You can do this, but it would be a 3 dimensional array of pointers,
which is probably not what you want. Why not just allocate a memory and
"cast" the pointer to an array?


--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to [EMAIL PROTECTED]
Please read the FAQ at http://kernelnewbies.org/FAQ

Reply via email to