EXAM 2 Topics Flashcards
What is dynamic memory?
Memory that is allocated during runtime (the execution of a program).
What is malloc?
Memory allocation. Used to allocate a specified number of bytes of memory. It reserves space.
What is calloc?
Contiguous Allocation. Similar to malloc, but it also initializes the allocated memory to 0
Initializes null, gets space on heap and returns and puts all 0s/nulls in space.
What is realloc?
Reallocate. Used to resize a previously allocated block of memory. Makes memory bigger or smaller, can’t call realloc on something in stack.
What is free?
Deallocates memory previously allocated on heap. One argument, pointer to dynamic memory and return memory back to system.
What is a memory leak?
Program allocates memory, but fails to release memory when it isn’t needed. Program holds memory and consumes system resources.
What is a dangling pointer?
Pointer that is still pointing to memory location even after it’s been deallocated. Pointer points to unfreed memory. Set pointers to NULL after memory is freed.
What are the five main stages in program translation?
Preprocessor, Compiler, Assembler, Linker, Loader
What is the lexical analyzer?
Input character stream, outputs token stream. Breaks down into tokens: identifiers, operators, and literals.
What is the syntax analyzer?
Input token stream, output syntax tree I. Checks if syntax adheres to rules, output represents program’s structure.
What is the Semantic analyzer?
Input syntax tree I, output syntax tree II. Checks for violation of rules.
What is the compiler?
Converts human-readable source code into machine executable code. Input C program(.c) output Assembly(.o). CREATES AN ASSEMBLY LANGUAGE PROGRAM.
What is the preprocessor process?
Character stream -> Lexical Analyzer -> token stream -> syntax analyzer -> Syntax tree -> Semantic Analyzer-> intermediate code generator
What is the assembler?
Input Assembly(.o) output Machine Code. Translates assembly to machine code, converts to binary instructions and memory addresses. CREATES AN OBJECT MODULE.
What is the linker?
input Machine Code output Executable Load Module(.exe). Has access to Libraries. ‘Links’ different parts of program together so it is runnable. LINKS ALL OBJECT MODULES INTO AN EXECUTABLE.
What is the loader?
Input Executable Load Module(.exe) output Memory. Prepares program in memory to be executable. LOADS THE LINKED EXECUTABLE.