Arena storage pool: Difference between revisions
Content deleted Content added
added omit from ML/I |
|||
Line 97:
Uninitialized memory is allocated using the malloc function. To obtain the amount of memory that needs to be allocated, sizeof is used. Sizeof is not a normal C function, it is evaluated by the compiler to obtain the amount of memory needed.
<lang c>int *var = malloc(n*sizeof(int));
Typename *var = malloc(sizeof
Typename *var = malloc(sizeof
Since pointers to structures are needed so frequently, often a
typedef will define a type as being a pointer to the associated structure.
Line 118:
One can allocate space on the stack using the alloca() function. You do not
free memory that's been allocated with alloca
<lang c>Typename *var = alloca(sizeof
An object oriented approach will define a function for creating a new object of a class.
In these systems, the size of the memory that needs to be allocated for an instance of the
|