Functions and Memory in C: Allocating Memory on the Heap

C programming    |    Intermediate
  • 11 videos | 1h 32m 2s
  • Includes Assessment
  • Earns a Badge
Rating 4.5 of 18 users Rating 4.5 of 18 users (18)
C programmers can commonly use two kinds of memory: stack and heap. While stack memory is used to store local variables and is fully managed by C, it does have major limitations that are mitigated by heap memory. In this course, you will compare stack and heap memory, exploring the advantages and limitations of each. Then, you will allocate memory using the malloc() function and deallocate memory using free(). Next, you will examine dangling memory issues that can cause potentially dangerous security issues. You will also explore other common allocation functions like calloc() to zero out memory and realloc() to help when you underestimate how much memory an array will require. Finally, you will focus on pointers to struct objects. After completing this course, you'll be able to allocate memory malloc, calloc, and realloc; free memory; use pointers to structs; and avoid problems related to dangling pointers and memory leaks.

WHAT YOU WILL LEARN

  • Discover the key concepts covered in this course
    Contrast stack and heap memory
    Use malloc() to allocate memory on the heap
    Use the free() method to free stack memory that is not allocated
    Allocate space for arrays using malloc()
    Return pointers to heap locations from functions
  • Distinguish between dangling memory and memory leaks
    Contrast malloc(), calloc(), and realloc()
    Create pointers on struct objects
    Create pointer fields in structs
    Summarize the key concepts covered in this course

IN THIS COURSE

  • 2m 34s
  • 11m 18s
    Find out how to compare stack and heap memory. FREE ACCESS
  • Locked
    3.  Allocating Memory on the Heap Using malloc()
    8m 4s
    In this video, find out how to use malloc() to allocate memory on the heap. FREE ACCESS
  • Locked
    4.  Freeing Memory on the Heap Using free()
    11m 2s
    In this video, you will use the free() method to free stack memory that is not being used. FREE ACCESS
  • Locked
    5.  Creating Arrays on the Heap
    10m 23s
    In this video, learn how to allocate space for arrays using malloc(). FREE ACCESS
  • Locked
    6.  Returning Heap Pointers from Functions
    9m 49s
    In this video, you will return pointers to heap locations from functions. FREE ACCESS
  • Locked
    7.  Comparing Dangling Memory and Memory Leaks
    10m 5s
    In this video, you will learn the difference between dangling memory and memory leaks. FREE ACCESS
  • Locked
    8.  Using the calloc() and realloc() Functions
    8m 21s
    During this video, you will learn how to use malloc(), calloc(), and realloc(). FREE ACCESS
  • Locked
    9.  Creating Pointer Variables in a Struct
    7m 18s
    During this video, you will learn how to create pointers to struct objects. FREE ACCESS
  • Locked
    10.  Creating Pointers to Struct Objects
    9m 17s
    During this video, you will learn how to create pointer fields in structures. FREE ACCESS
  • Locked
    11.  Course Summary
    3m 52s
    bb960bfb-bfd9-4590-a6be-2598621fe8b1 FREE ACCESS

EARN A DIGITAL BADGE WHEN YOU COMPLETE THIS COURSE

Skillsoft is providing you the opportunity to earn a digital badge upon successful completion on some of our courses, which can be shared on any social network or business platform.

Digital badges are yours to keep, forever.

YOU MIGHT ALSO LIKE

PEOPLE WHO VIEWED THIS ALSO VIEWED THESE

Rating 4.5 of 154 users Rating 4.5 of 154 users (154)
Rating 4.3 of 131 users Rating 4.3 of 131 users (131)
Rating 4.5 of 44 users Rating 4.5 of 44 users (44)