void peek_linked_list(struct linked_list_t *linked_list, struct linked_list_node_t **linked_list_node_pointer) { /* allocates space for the linked list node */ struct linked_list_node_t *linked_list_node; /* retrieves the initial linked list node */ get_linked_list(linked_list, 0, &linked_list_node); /* sets the linked list node in the linked list node pointer */ *linked_list_node_pointer = linked_list_node; }
void get_value_linked_list(struct linked_list_t *linked_list, size_t index, void **value_pointer) { /* allocates space for the linked list node */ struct linked_list_node_t *linked_list_node; /* retrieves the linked list node for the index */ get_linked_list(linked_list, index, &linked_list_node); /* sets the linked list node value in the value pointer */ *value_pointer = linked_list_node->value; }
void peek_top_linked_list(struct linked_list_t *linked_list, struct linked_list_node_t **linked_list_node_pointer) { /* allocates space for the linked list node */ struct linked_list_node_t *linked_list_node; /* retrieves the initial linked list node, note that there is a validation on the size of the linked list */ get_linked_list(linked_list, linked_list->size > 0 ? linked_list->size - 1 : 0, &linked_list_node); /* sets the linked list node in the linked list node pointer */ *linked_list_node_pointer = linked_list_node; }
void pop_linked_list(struct linked_list_t *linked_list, struct linked_list_node_t **linked_list_node_pointer) { /* allocates space for the linked list node */ struct linked_list_node_t *linked_list_node; /* retrieves the initial linked list node */ get_linked_list(linked_list, 0, &linked_list_node); /* removes the first linked list node from the linked list */ remove_linked_list(linked_list, linked_list_node, 0); /* sets the linked list node in the linked list node pointer */ *linked_list_node_pointer = linked_list_node; }
void print_linked_list_bin(LinkedList *list){ /** * Prints the specified linked list to the console. Each element's data * is printed byte-wise as a hexadecimal. */ printf("\n"); int n = count_linked_list(list); printf("Linked List of length %d:\n", n); print_separator_line('-'); int i; for(i = 0; i < n; i++){ printf("%3d || ", i); void *data = get_linked_list(list, i); print_byte_data_bin(data, list->data_size); printf("\n"); } print_separator_line('-'); }