Fix adding cards to linked list
This commit is contained in:
parent
9c135dac88
commit
da84a7de9d
@ -47,7 +47,7 @@ void rfid_add_card(const card_t *card)
|
|||||||
new_card = malloc(sizeof(card_t));
|
new_card = malloc(sizeof(card_t));
|
||||||
new_card_user = malloc(strlen(card->user)+1);
|
new_card_user = malloc(strlen(card->user)+1);
|
||||||
if (!new_card || !new_card_user) {
|
if (!new_card || !new_card_user) {
|
||||||
printf(PSTR("Out of memory. Please remove cards.\n"));
|
printf_P(PSTR("Out of memory. Please remove cards.\n"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,6 +56,7 @@ void rfid_add_card(const card_t *card)
|
|||||||
memcpy(new_card->uid, card->uid, card->uid_size);
|
memcpy(new_card->uid, card->uid, card->uid_size);
|
||||||
strcpy(new_card_user, card->user);
|
strcpy(new_card_user, card->user);
|
||||||
new_card->user = new_card_user;
|
new_card->user = new_card_user;
|
||||||
|
new_card->next = NULL;
|
||||||
|
|
||||||
// Update card list
|
// Update card list
|
||||||
if (head == NULL) {
|
if (head == NULL) {
|
||||||
@ -73,7 +74,7 @@ void rfid_add_card(const card_t *card)
|
|||||||
|
|
||||||
void rfid_list_cards(void) {
|
void rfid_list_cards(void) {
|
||||||
if (head == NULL) {
|
if (head == NULL) {
|
||||||
printf_P(PSTR("No cards added"));
|
printf_P(PSTR("No cards added\n"));
|
||||||
} else {
|
} else {
|
||||||
card_t *current;
|
card_t *current;
|
||||||
current = head;
|
current = head;
|
||||||
@ -81,7 +82,6 @@ void rfid_list_cards(void) {
|
|||||||
rfid_print_card(current);
|
rfid_print_card(current);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
current = current->next;
|
current = current->next;
|
||||||
|
|
||||||
}
|
}
|
||||||
rfid_print_card(current);
|
rfid_print_card(current);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user