summaryrefslogtreecommitdiffstats
path: root/src/afb-apiset.c
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2018-04-27 15:55:43 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2018-06-13 17:14:53 +0200
commit285fc5b291793dfbfe05625d352bd326e224b700 (patch)
tree34727190469b6b208b0896755140582922a202c1 /src/afb-apiset.c
parent95ee37b3cdb38efc4e77d072d00c7fc46b203d24 (diff)
afb-apiset: manage deletion of apis
Change-Id: If8b4a2b8773e5e7ce3ae62839193c611eefcb811 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afb-apiset.c')
-rw-r--r--src/afb-apiset.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/afb-apiset.c b/src/afb-apiset.c
index a373c207..8d76bbfe 100644
--- a/src/afb-apiset.c
+++ b/src/afb-apiset.c
@@ -264,21 +264,28 @@ error:
*/
int afb_apiset_del(struct afb_apiset *set, const char *name)
{
- int i, c;
+ struct api_desc *i, *e;
+ int c;
/* search the api */
- for (i = 0 ; i < set->count ; i++) {
- c = strcasecmp(set->apis[i].name, name);
+ i = set->apis;
+ e = i + set->count;
+ while (i != e) {
+ c = strcasecmp(i->name, name);
if (c == 0) {
+ if (i->api.itf->unref)
+ i->api.itf->unref(i->api.closure);
set->count--;
- while(i < set->count) {
- set->apis[i] = set->apis[i + 1];
+ e--;
+ while (i != e) {
+ i[0] = i[1];
i++;
}
return 0;
}
if (c > 0)
break;
+ i++;
}
errno = ENOENT;
return -1;