From 3b1eab0e62fe8903886932d8e24f34a6d22bba1d Mon Sep 17 00:00:00 2001 From: Arman Uguray Date: Wed, 7 Jan 2015 21:48:19 -0800 Subject: [PATCH] shared/gatt-db: Add gatt_db_attribute_reset This patch adds the gatt_db_attribute_reset function, which clears the value of an attribute that is stored in the database. --- src/shared/gatt-db.c | 15 +++++++++++++++ src/shared/gatt-db.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c index eac7948fe..9a9cadcee 100644 --- a/src/shared/gatt-db.c +++ b/src/shared/gatt-db.c @@ -1544,3 +1544,18 @@ bool gatt_db_attribute_write_result(struct gatt_db_attribute *attrib, return true; } + +bool gatt_db_attribute_reset(struct gatt_db_attribute *attrib) +{ + if (!attrib) + return false; + + if (!attrib->value || !attrib->value_len) + return true; + + free(attrib->value); + attrib->value = NULL; + attrib->value_len = 0; + + return true; +} diff --git a/src/shared/gatt-db.h b/src/shared/gatt-db.h index 2edd13f52..1f4005eaf 100644 --- a/src/shared/gatt-db.h +++ b/src/shared/gatt-db.h @@ -207,3 +207,5 @@ bool gatt_db_attribute_write(struct gatt_db_attribute *attrib, uint16_t offset, bool gatt_db_attribute_write_result(struct gatt_db_attribute *attrib, unsigned int id, int err); + +bool gatt_db_attribute_reset(struct gatt_db_attribute *attrib); -- 2.47.3