5 link_t
* list_new(int value
) {
7 link_t_new
= malloc(sizeof(link_t
));
8 link_t_new
->value
= value
;
9 link_t_new
->next
= NULL
;
13 link_t
* list_append(link_t
* head
, int value
) {
16 return head
= list_new(value
);
18 link_t
* head_first
= head
;
19 while (head
->next
!= NULL
) {
22 head
->next
= list_new(value
);
27 link_t
* list_prepend(link_t
* head
, int value
) {
28 link_t
* first_link
= list_new(value
);
30 first_link
->next
= head
;
34 unsigned list_count(link_t
* head
) {
37 if (head
== NULL
) { return 0; }
38 while (head
->next
!= NULL
) {
45 void list_set(link_t
* head
, unsigned index
, int value
) {
47 // FIXME: check for the index value validity
48 for (unsigned count
= 0; count
< index
; count
++) {
54 int list_get(link_t
* head
, unsigned index
) {
56 if (index
< list_count(head
)) {
57 for (unsigned i
= 0; i
< index
; i
++) {
66 void list_clear(link_t
* link
) {
68 while (link
!= NULL
) {
69 link_t
* next_link
= link
->next
;