Dynamic Memory Flashcards
malloc parameter(s)
size of block in bytes
malloc return type
void pointer to allocated segment
calloc parameter(s)
number of items, size of item in bytes
calloc return type
void pointer to allocated segment
realloc parameter(s)
original pointer, new block size in bytes
What happens if memory allocation fails?
NULL pointer is returned
Dynamic memory functions are stored in what library?
stdlib.h
Types of memory violations
Memory leak, Dangling pointer, Use after free, Double Free, Freeing static memory
Not freeing dynamically allocated memory
memory leak
Using unallocated pointers
Dangling pointer
Using pointers recently freed
Dangling pointer
Dereferencing after free
Use after free
Freeing the same thing twice
Double free
What happens if you dereference NULL?
Segfault
What happens if you free NULL?
Nothing