Malloc and automatic variables

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

 



Hello,
I want to use malloc in embedded environment, where there is no memory
management at all - I know it sounds like a bad idea but this malloc
will be called only once somewhere at program start and it wont be
released ever, so memory fragmentation shouldn't be a problem. Unless
there is something i don't know.

Let's assume I have this function

int* vector = 0;
void init(int cnt)
{
   int something = 100;
   vector = malloc(sizeof(int) * cnt);
}

So when above function is called it allocate automatic variable
"something", then allocates memory for vector - after work is done
"something" is freed.
Question is, will I end up with gaping hole in memory between:
(A) memory allocated before this function is called
and
(B) memory allocated by function for vector

###MEMORY_USED_BEFORE###(int sized hole)###MEMORY_FOR_VECTOR###

Or maybe automatic variables are created somewhere else (stack?) and
memory wont be fragmented.
In case it would be significant I'll add that target environment is
ARM Cortex 3.


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux