Added a tutorial and fix few errors
[src/app-framework-binder.git] / include / afb / c++ / binding-wrap.hpp
index 04f4add..ae0e5ee 100644 (file)
@@ -90,6 +90,7 @@ bool callsync(const char *api, const char *verb, struct json_object *args, struc
 /* apis */
 class api
 {
+protected:
        afb_api_t api_;
 public:
        using call_cb = void (*)(void *closure, struct json_object *object, const char *error, const char *info, afb_api_t api);
@@ -406,7 +407,7 @@ inline bool event::is_valid() const { return afb_event_is_valid(event_); }
 inline int event::broadcast(json_object *object) const { return afb_event_broadcast(event_, object); }
 inline int event::push(json_object *object) const { return afb_event_push(event_, object); }
 
-inline void event::unref() { afb_event_unref(event_); event_ = nullptr; }
+inline void event::unref() { if (event_) { afb_event_unref(event_); } event_ = nullptr; }
 inline void event::addref() { afb_event_addref(event_); }
 inline const char *event::name() const { return afb_event_name(event_); }