INTRODUCTION TO MEMORY ALLOCATION IN "C"

Best Blogger Tips
=>FILE HANDLING IN C:

1) STATIC MEMORY ALLOCATION

2) DYANAMIC MEMORY ALLOCATION

BRIF DISCUSS ABOUT POINTS:

> In SMA memory is assign to varible at the starting of the program while in DMA memory is allocated at
 the running time of program.

>In SMA memory is fixed in case of DMA memory can be changed.

>In SMA inefficient use of memory while in case of DMA efficient use of memory.

>In DMA memory can be expanded or contracted.So this provide flexibility tn programmer.

=>DYNAMIC MEMORY ALLOCATION FUNCTION:

1) MALLOC( )

2) CALLOC( )

3) FREE( )

4) REALLOC( )

BRIEF DISCUSSION ABOUT POINTS:

1) MALLOC( ):- Function is used to allocate single block of memory.

>If request is granted then it returns a null pointer to the starting of the block.

>If request is not granted then returns a null pointer.

>All the allocated bytes are uninitilized and contain garbage value.

2) CALLOC( ):- Function is used to allocate multiple blocks of memory.

>All the allocated bytes are initilized and not contain garbage value(any value) but contain zero.

3) FREE( ):- Function is used to deallocate the previously allocated memory.

4) REALLOC( ):- Function is used to resize the previously allacted memory.

Kindly Share The Love »»

Save on Delicious

No comments:

Post a Comment