Change soft-fail to use the config, rather than env
[rbx.git] / spec / subtend / ext / subtend_define_alloc_func.c
blobe8416b96f42616d1f8609960e4797237e192f66b
1 #include <ruby.h>
2 #include <string.h>
4 struct sample_wrapped_struct {
5 int foo;
6 };
8 VALUE sdaf_alloc_func(VALUE klass) {
9 struct sample_wrapped_struct* bar = (struct sample_wrapped_struct *)malloc(sizeof(struct sample_wrapped_struct));
10 bar->foo = 42;
11 return Data_Wrap_Struct(klass, NULL, NULL, bar);
14 VALUE sdaf_get_struct(VALUE self) {
15 struct sample_wrapped_struct* bar;
16 Data_Get_Struct(self, struct sample_wrapped_struct, bar);
18 return INT2FIX((*bar).foo);
21 void Init_subtend_define_alloc_func() {
22 VALUE cls;
23 cls = rb_define_class("SubtendAlloc", rb_cObject);
24 rb_define_alloc_func(cls, sdaf_alloc_func);
25 rb_define_method(cls, "wrapped_data", sdaf_get_struct, 0);