From 51996f20c2bd5280050bad644eceff8ddcd57e9a Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Sun, 10 Nov 2013 17:50:00 +0100 Subject: tag: Create new path when writing a new Record By resetting n_records to 0 after successfully writing a new Record, the newly written Record would be exposed with the same path as the previous one. n_records become next_record and tracks the next available record index. --- src/tag.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/tag.c b/src/tag.c index 1dd0a61..c5ed1f8 100644 --- a/src/tag.c +++ b/src/tag.c @@ -55,7 +55,7 @@ struct near_tag { size_t data_length; uint8_t *data; - uint32_t n_records; + uint32_t next_record; GList *records; bool blank; @@ -266,7 +266,6 @@ static void write_cb(uint32_t adapter_idx, uint32_t target_idx, int status) } near_ndef_records_free(tag->records); - tag->n_records = 0; tag->records = NULL; g_free(tag->data); tag->data = NULL; @@ -584,7 +583,7 @@ static int tag_initialize(struct near_tag *tag, tag->adapter_idx = adapter_idx; tag->target_idx = target_idx; tag->protocol = protocols; - tag->n_records = 0; + tag->next_record = 0; tag->readonly = false; if (nfcid_len <= NFC_MAX_NFCID1_LEN) { @@ -752,14 +751,14 @@ int near_tag_add_records(struct near_tag *tag, GList *records, path = g_strdup_printf("%s/nfc%d/tag%d/record%d", NFC_PATH, tag->adapter_idx, - tag->target_idx, tag->n_records); + tag->target_idx, tag->next_record); if (!path) continue; __near_ndef_record_register(record, path); - tag->n_records++; + tag->next_record++; tag->records = g_list_append(tag->records, record); } -- cgit v1.2.3