Re: variables or alloc?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2004-12-17 at 08:44 -0800, Alaios wrote:
> Just another question... For the kernel code do u
> prefer create variables declaring them e.x int myint;
> char mychar;
> ...
> ...
> etc
> 
> Or do u use alloc instead?
> 
> Can u plz tell me when it is better to use the first
> way and when the second?

If you need to have bigger chunks of memory use kmalloc (because it
doesn't use the stack) and if you have some small variables or small
structures the stack is fine.

The reason is that the stack space is finite and we don't want to
overflow it.

btw, there's no point in doing "alloc" for something like int myint, you
still need a pointer to the memory to keep track of it.


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/




[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux