mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-22 05:14:46 -07:00
fmt
This commit is contained in:
@@ -1,23 +1,23 @@
|
||||
#include "list.h"
|
||||
|
||||
ListNode *list_init_head(void* data) {
|
||||
ListNode *new = (ListNode *) malloc(sizeof(ListNode));
|
||||
ListNode* list_init_head(void* data) {
|
||||
ListNode* new = (ListNode*)malloc(sizeof(ListNode));
|
||||
new->data = data;
|
||||
new->next = NULL;
|
||||
return new;
|
||||
}
|
||||
|
||||
ListNode *list_add(ListNode *head, void* data) {
|
||||
ListNode *new = (ListNode *) malloc(sizeof(ListNode));
|
||||
ListNode* list_add(ListNode* head, void* data) {
|
||||
ListNode* new = (ListNode*)malloc(sizeof(ListNode));
|
||||
new->data = data;
|
||||
new->next = NULL;
|
||||
|
||||
if (head == NULL)
|
||||
if(head == NULL)
|
||||
head = new;
|
||||
else {
|
||||
ListNode *it;
|
||||
ListNode* it;
|
||||
|
||||
for (it = head; it->next != NULL; it = it->next)
|
||||
for(it = head; it->next != NULL; it = it->next)
|
||||
;
|
||||
|
||||
it->next = new;
|
||||
@@ -26,33 +26,33 @@ ListNode *list_add(ListNode *head, void* data) {
|
||||
return head;
|
||||
}
|
||||
|
||||
ListNode *list_find(ListNode *head, void* data) {
|
||||
ListNode *it;
|
||||
ListNode* list_find(ListNode* head, void* data) {
|
||||
ListNode* it;
|
||||
|
||||
for (it = head; it != NULL; it = it->next)
|
||||
if (it->data == data)
|
||||
break;
|
||||
for(it = head; it != NULL; it = it->next)
|
||||
if(it->data == data) break;
|
||||
|
||||
return it;
|
||||
}
|
||||
|
||||
ListNode *list_element_at(ListNode *head, uint16_t index) {
|
||||
ListNode *it;
|
||||
ListNode* list_element_at(ListNode* head, uint16_t index) {
|
||||
ListNode* it;
|
||||
uint16_t i;
|
||||
for (it = head, i = 0; it != NULL && i < index; it = it->next, i++);
|
||||
for(it = head, i = 0; it != NULL && i < index; it = it->next, i++)
|
||||
;
|
||||
return it;
|
||||
}
|
||||
|
||||
ListNode *list_remove(ListNode *head, ListNode *ep) {
|
||||
if (head == ep) {
|
||||
ListNode *new_head = head->next;
|
||||
ListNode* list_remove(ListNode* head, ListNode* ep) {
|
||||
if(head == ep) {
|
||||
ListNode* new_head = head->next;
|
||||
free(head);
|
||||
return new_head;
|
||||
}
|
||||
|
||||
ListNode *it;
|
||||
ListNode* it;
|
||||
|
||||
for (it = head; it->next != ep; it = it->next)
|
||||
for(it = head; it->next != ep; it = it->next)
|
||||
;
|
||||
|
||||
it->next = ep->next;
|
||||
@@ -61,10 +61,10 @@ ListNode *list_remove(ListNode *head, ListNode *ep) {
|
||||
return head;
|
||||
}
|
||||
|
||||
void list_free(ListNode *head) {
|
||||
void list_free(ListNode* head) {
|
||||
ListNode *it = head, *tmp;
|
||||
|
||||
while (it != NULL) {
|
||||
while(it != NULL) {
|
||||
tmp = it;
|
||||
it = it->next;
|
||||
free(tmp);
|
||||
|
||||
Reference in New Issue
Block a user