summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2013-11-10 17:50:00 +0100
committerSamuel Ortiz <sameo@linux.intel.com>2013-11-10 17:57:09 +0100
commit51996f20c2bd5280050bad644eceff8ddcd57e9a (patch)
tree0a53a08d62942ea4981928803cbcd62d0fc2a2db
parent196262d4e0a45f3f2262ebaab81edb1427c32aee (diff)
downloadneard-51996f20c2bd5280050bad644eceff8ddcd57e9a.tar.gz
neard-51996f20c2bd5280050bad644eceff8ddcd57e9a.tar.bz2
neard-51996f20c2bd5280050bad644eceff8ddcd57e9a.zip
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.
-rw-r--r--src/tag.c9
1 files 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);
}