Hey everyone
...
Thank you,
Lster
Array Allocation
Array Allocation
Last edited by Lprogster on Tue Oct 23, 2007 11:22 am, edited 1 time in total.
- mathematician
- Member
- Posts: 437
- Joined: Fri Dec 15, 2006 5:26 pm
- Location: Church Stretton Uk
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
gcc will put the array on the stack, somewhere within the functions stack frame. The address itself is simple to get:
unsigned int address = (unsigned int) &(array[0]);
nevertheless, its bad practice to create large arrays on the stack in kernel code. Even a set of small arrays can quickly overflow the stack. Using things other than (unsigned) char will only make matters worse by several factors. Unless you know for sure the array will always fit within the stack, do not allocate it there.
unsigned int address = (unsigned int) &(array[0]);
nevertheless, its bad practice to create large arrays on the stack in kernel code. Even a set of small arrays can quickly overflow the stack. Using things other than (unsigned) char will only make matters worse by several factors. Unless you know for sure the array will always fit within the stack, do not allocate it there.