Wrap / unwrap hbsdctrl_ctx_t
Remove unneccessary abstraction
This commit is contained in:
parent
fd7e5e26f4
commit
af0c4b776f
3 changed files with 7 additions and 19 deletions
|
@ -5,32 +5,24 @@
|
|||
|
||||
static int FLAGS = HBSDCTRL_FEATURE_STATE_FLAG_NONE;
|
||||
static const char *NAMESPACE = LIBHBSDCONTROL_DEFAULT_NAMESPACE;
|
||||
static void bsdcontrol_context_free(struct bsdcontrol_ctx_t *);
|
||||
static void bsdcontrol_context_free(hbsdctrl_ctx_t *);
|
||||
|
||||
VALUE
|
||||
bsdcontrol_context_alloc(VALUE klass)
|
||||
{
|
||||
hbsdctrl_ctx_t *ctx;
|
||||
struct bsdcontrol_ctx_t *rbctx;
|
||||
ctx = hbsdctrl_ctx_new(FLAGS, NAMESPACE);
|
||||
rbctx = calloc(1, sizeof(struct bsdcontrol_ctx_t));
|
||||
if (ctx == NULL)
|
||||
{
|
||||
rb_raise(rb_eSystemCallError, "hbsdctrl_ctx_new");
|
||||
}
|
||||
else if (rbctx == NULL)
|
||||
{
|
||||
rb_raise(rb_eSystemCallError, "calloc");
|
||||
}
|
||||
rbctx->ctx = ctx;
|
||||
return Data_Wrap_Struct(klass, NULL, bsdcontrol_context_free, rbctx);
|
||||
return Data_Wrap_Struct(klass, NULL, bsdcontrol_context_free, ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
bsdcontrol_context_free(struct bsdcontrol_ctx_t *rbctx)
|
||||
bsdcontrol_context_free(hbsdctrl_ctx_t *ctx)
|
||||
{
|
||||
hbsdctrl_ctx_free(&rbctx->ctx);
|
||||
free(rbctx);
|
||||
hbsdctrl_ctx_free(&ctx);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
#include <ruby.h>
|
||||
#include <libhbsdcontrol.h>
|
||||
|
||||
struct bsdcontrol_ctx_t {
|
||||
hbsdctrl_ctx_t *ctx;
|
||||
};
|
||||
|
||||
VALUE bsdcontrol_context_alloc(VALUE);
|
||||
VALUE bsdcontrol_context_library_version(VALUE);
|
||||
VALUE bsdcontrol_context_available_features(VALUE);
|
||||
|
|
|
@ -20,9 +20,9 @@ bsdcontrol_open(VALUE path)
|
|||
hbsdctrl_ctx_t *
|
||||
bsdcontrol_unwrap(VALUE rbcontext)
|
||||
{
|
||||
struct bsdcontrol_ctx_t *rbctx;
|
||||
Data_Get_Struct(rbcontext, struct bsdcontrol_ctx_t, rbctx);
|
||||
return rbctx->ctx;
|
||||
hbsdctrl_ctx_t *ctx;
|
||||
Data_Get_Struct(rbcontext, hbsdctrl_ctx_t, ctx);
|
||||
return ctx;
|
||||
}
|
||||
|
||||
hbsdctrl_feature_t *
|
||||
|
|
Loading…
Reference in a new issue