Computer Science 215 Quiz O Name ______________________ 1. If a C program mallocs an area of memory and fails to free it, a. A garbage collector built b. The OS will reclaim all of the into the C language will memory used by the program including reclaim it unfreed malloc'd areas when the program exits. c. The memory will remain unusable d. The memory will remain permanently until the system is rebooted allocated and the computer will eventually have to be sent back to the factory for memory replacement 2. Suppose a buffer is declared as a local variable as follows: unsigned char buffer[512]; The function that contains the declaration a. must include a free(buffer); b. must NOT do free(buffer); to avoid a memory leak c. may do a free(buffer) but if it doesn't there will be no leak 3. Assuming "lst" points to the head a list of structures of type obj_t, best characterizes the following code fragment: obj_t *temp = malloc(sizeof(obj_t)); temp = lst->head; a. it will cause a memory leak b. it will cause a seg fault c. it is the correct way to set temp to point to the first object in the list. 4. Which would be the best way to reformulate the above code: a. obj_t *temp = malloc(sizeof(obj_t)); b. obj_t *temp = NULL; free(temp); temp = lst->head; temp = lst->head; c. The code was PERFECT as it was annd should be reformulated 5. What best describes this reformulation: obj_t *temp = malloc(sizeof(obj_t)); free(temp); temp = lst->head; a. The call to free() will cause b. Its mildly inefficient a seg fault. but won't cause any major problem c. It creates a major memory leak