Aktualizovat du6/list_ops.c

This commit is contained in:
Denys Sanchuk 2025-04-08 12:44:41 +00:00
parent 70ef5aebab
commit 214bf9cafa

View File

@ -0,0 +1,13 @@
#include "list_ops.h"
#include <string.h>
list_t *new_list(size_t length, list_element_t elements[]) {
list_t *list = malloc(sizeof(list_t) + sizeof(list_element_t) * length);
if (!list) return NULL;
list->length = length;
if (elements && length > 0) {
memcpy(list->elements, elements, sizeof(list_element_t) * length);
}
return list;
}