Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ruby.h>
- void t_free(Image *m)
- {
- myown_free(*m);
- free(m);
- }
- static VALUE t_allocate(VALUE obj)
- {
- struct my *m = malloc(sizeof(struct my));
- if( m == NULL )
- rb_raise(rb_eNoMemError, "Brakuje pamięci na obiekt Obraz (%zu bajty)", sizeof(struct my));
- return Data_Wrap_Struct(obj, NULL, t_free, m);
- }
- how creating ???
- VALUE t_neww(VALUE obiekt)
- {
- VALUE obj;
- obj = t_allocate(obiekt);
- rb_obj_call_init(obj, 1, NULL);
- return obj;
- }
- void Init_My()
- {
- ca = rb_define_class("MyOwn", rb_cObject);
- rb_define_alloc_func(ca,t_allocate);
- rb_define_method(ca, "initialize", t_init, 2); //it working
- rb_define_method(ca, "neww", t_neww, 0); // it no working
Advertisement
Add Comment
Please, Sign In to add comment