Aktualizovat du6/list_ops.c
This commit is contained in:
parent
70ef5aebab
commit
214bf9cafa
@ -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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user