From 9cbff28c8a97e7a5dc36f6e6225a9d5e2eab8f06 Mon Sep 17 00:00:00 2001 From: Jose Bollo Date: Wed, 25 Jul 2018 15:05:08 +0200 Subject: [PATCH] afb-api-v3: Simplify the code Having a code more easy to read is better here. Change-Id: I429e82d87729e41ec53d0852daa6f146261443c9 Signed-off-by: Jose Bollo --- src/afb-api-v3.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/afb-api-v3.c b/src/afb-api-v3.c index 02853b12..7f63b6eb 100644 --- a/src/afb-api-v3.c +++ b/src/afb-api-v3.c @@ -325,19 +325,16 @@ int afb_api_v3_del_verb( const char *verb, void **vcbdata) { - struct afb_verb_v3 **v, **e, *i; + struct afb_verb_v3 *v; + int i; - v = api->verbs; - e = &v[api->count]; - while (v != e) { - i = *v++; - if (!strcasecmp(i->verb, verb)) { - api->count--; + for (i = 0 ; i < api->count ; i++) { + v = api->verbs[i]; + if (!strcasecmp(verb, v->verb)) { + api->verbs[i] = api->verbs[--api->count]; if (vcbdata) - *vcbdata = i->vcbdata; - if (v != e) - *--v = *--e; - free(i); + *vcbdata = v->vcbdata; + free(v); return 0; } } -- 2.16.6