summaryrefslogtreecommitdiffstats
path: root/ctl-lib/ctl-plugin.h
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-10-25 19:10:45 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-10-25 19:10:45 +0200
commite9205ca171ed794ac18dcdec40578955a64361f3 (patch)
tree8f37a71741fab56425fd5960c358d93317f9e4aa /ctl-lib/ctl-plugin.h
parentf7344342f4c3277d3240b75d91df53c890e8fea3 (diff)
Replace macro by apiV2 compatible inline function
Signature from apiv2 and apiv3 aren't the same so better use an inline function here to be able to return a pointer. Change-Id: I2e811a37337ca1a4f1015a060e147c69370aa63c Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'ctl-lib/ctl-plugin.h')
-rw-r--r--ctl-lib/ctl-plugin.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/ctl-lib/ctl-plugin.h b/ctl-lib/ctl-plugin.h
index d02670d..2613f9b 100644
--- a/ctl-lib/ctl-plugin.h
+++ b/ctl-lib/ctl-plugin.h
@@ -128,6 +128,13 @@
#define AFB_ClientCtxSet(request, replace, createCB, freeCB, handle) afb_req_context_set(request, createCB(handle), freeCB)
#define AFB_ClientCtxClear(request) afb_req_context_clear(request)
+ static inline void* AFB_ClientCtxSet(afb_req request, int replace, void *(*create_context)(void *closure), void (*free_context)(void*), void *closure)
+ {
+ void *ctx = create_context(closure);
+ if(ctx)
+ {afb_req_context_set(request, ctx, free_context);}
+ return ctx;
+ }
#define AFB_ApiVerbs afb_verb_v2