2857042028966a52133304c9bd73d23534b8c22b
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 count
; }
39 while (head
->next
!= NULL
) {
46 void list_set(link_t
* head
, unsigned index
, int value
) {
48 // FIXME: check for the index value validity
49 for (unsigned count
= 0; count
< index
; count
++) {
55 int list_get(link_t
* head
, unsigned index
) {
57 if (index
< list_count(head
)) {
58 for (unsigned i
= 0; i
< index
; i
++) {
67 void list_clear(link_t
* link
) {
69 while (link
!= NULL
) {
70 link_t
* next_link
= link
->next
;