Dynamic Memory Allocation - Introduction to Programming - Lecture Slides, Slides of Computer Programming

Dynamic memory allocation, Advantages of Dynamic memory allocation, Disadvantages of static memory allocation, Programming errors, Compile Time Allocation, Heap are the key points of this lecture.

Typology: Slides

2011/2012

Uploaded on 11/06/2012

somo
somo 🇮🇳

4.8

(4)

70 documents

1 / 34

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Introduction to Programming
Lecture 24
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22

Partial preview of the text

Download Dynamic Memory Allocation - Introduction to Programming - Lecture Slides and more Slides Computer Programming in PDF only on Docsity!

Introduction to Programming

Lecture 24

Today’s Agenda

 Memory Allocation

  • Dynamic memory allocation
  • Advantages/disadvantages of

Dynamic and static memory

allocation

  • Common programming errors while

using Dynamic memory allocation

Compile Time Allocation

Dynamic Memory Allocation

Pointers

void

Pointer

void *ptr ;

Cast

( int * ) ptr ;

NULL

calloc ( 1000 , sizeof ( int ) ) ;

( int * ) calloc ( 1000 , sizeof ( int ) ) ;

Example 1 int *iPtr ; iPtr = ( int * ) calloc ( 1000 , sizeof ( int ) ) ; if ( iPtr == NULL ) exit ( ) ;

void * malloc ( n ) ;

Number of
bytes required