#include "list_ops.h" #include #include list_t *new_list(size_t length, list_element_t elements[]) { size_t size = sizeof(list_t) + length * sizeof(list_element_t); list_t *newList = (list_t *)malloc(size); if (newList == NULL) { return NULL; } newList->length = length; for (size_t i = 0; i < length; ++i) { newList->elements[i] = elements[i]; } return newList; }