Memory Allocation

Last time: More on Pointers

Prof. Brian D. Davison

Computer Science & Engineering, Lehigh University

Additional Credits

Pointers and Storage

Static vs. Dynamic Allocation

Note the cast from malloc() -- this is because malloc returns void *

Why dynamic allocation?

calloc()

How much to allocate?

Potential Problem

Nothing "potential" here -- this is definitely a problem.

Returning memory

Returning memory

realloc()

Automatic array expansion

Need to use pointers to pointers!

Code review of rdice.c