diff --git a/attrib/gatt-service.c b/attrib/gatt-service.c
index ead3f8e..b904ce6 100644
--- a/attrib/gatt-service.c
+++ b/attrib/gatt-service.c
g_free(info);
}
-void gatt_service_add(uint16_t uuid, uint16_t svc_uuid, gatt_option opt1, ...)
+gboolean gatt_service_add(uint16_t uuid, uint16_t svc_uuid, gatt_option opt1, ...)
{
uint16_t start_handle, h;
unsigned int size;
start_handle = attrib_db_find_avail(size);
if (start_handle == 0) {
error("Not enough free handles to register service");
- goto done;
+ g_slist_free_full(chrs, free_gatt_info);
+ return FALSE;
}
DBG("New service: handle 0x%04x, UUID 0x%04x, %d attributes",
struct gatt_info *info = l->data;
DBG("New characteristic: handle 0x%04x", h);
- if (!add_characteristic(&h, info))
- goto done;
+ if (!add_characteristic(&h, info)) {
+ g_slist_free_full(chrs, free_gatt_info);
+ return FALSE;
+ }
}
g_assert(size < USHRT_MAX);
g_assert(h - start_handle == (uint16_t) size);
-
-done:
g_slist_free_full(chrs, free_gatt_info);
+
+ return TRUE;
}
diff --git a/attrib/gatt-service.h b/attrib/gatt-service.h
index 6525dc0..95064c0 100644
--- a/attrib/gatt-service.h
+++ b/attrib/gatt-service.h
ATTRIB_WRITE,
} attrib_event_t;
-void gatt_service_add(uint16_t uuid, uint16_t svc_uuid, gatt_option opt1, ...);
+gboolean gatt_service_add(uint16_t uuid, uint16_t svc_uuid, gatt_option opt1, ...);