diff options
author | Ali Polatel <alip@exherbo.org> | 2010-05-26 18:54:25 +0300 |
---|---|---|
committer | Ali Polatel <alip@exherbo.org> | 2010-06-06 09:17:47 +0300 |
commit | c7893408bbe6904ae7da97aa203587af4ec2fac7 (patch) | |
tree | 9139c51aff243eb0fdfaac35d75c557c0f7de29e /bindings/ruby/directory.c | |
parent | 35925e6e5be58ca33d8f40f1d6ec44b4e7799713 (diff) |
ruby: Kill garbage collection related cruft.
Let the user destroy objects that she wants explicitly.
It's not possible to specify the order objects are garbage collected.
See id:86y6f8v838.fsf@harikalardiyari.ev on ruby-talk for more
information.
Diffstat (limited to 'bindings/ruby/directory.c')
-rw-r--r-- | bindings/ruby/directory.c | 58 |
1 files changed, 34 insertions, 24 deletions
diff --git a/bindings/ruby/directory.c b/bindings/ruby/directory.c index 46fe11cf..e73658c1 100644 --- a/bindings/ruby/directory.c +++ b/bindings/ruby/directory.c @@ -21,6 +21,23 @@ #include "defs.h" /* + * call-seq: DIR.destroy => nil + * + * Destroys the directory, freeing all resources allocated for it. + */ +VALUE +notmuch_rb_directory_destroy(VALUE self) +{ + notmuch_directory_t *dir; + + Data_Get_Struct(self, notmuch_directory_t, dir); + + notmuch_directory_destroy(dir); + + return Qnil; +} + +/* * call-seq: DIR.mtime => fixnum * * Returns the mtime of the directory or +0+ if no mtime has been previously @@ -29,11 +46,11 @@ VALUE notmuch_rb_directory_get_mtime(VALUE self) { - notmuch_rb_directory_t *dir; + notmuch_directory_t *dir; - Data_Get_Struct(self, notmuch_rb_directory_t, dir); + Data_Get_Struct(self, notmuch_directory_t, dir); - return UINT2NUM(notmuch_directory_get_mtime(dir->nm_dir)); + return UINT2NUM(notmuch_directory_get_mtime(dir)); } /* @@ -45,15 +62,16 @@ VALUE notmuch_rb_directory_set_mtime(VALUE self, VALUE mtimev) { notmuch_status_t ret; - notmuch_rb_directory_t *dir; + notmuch_directory_t *dir; - Data_Get_Struct(self, notmuch_rb_directory_t, dir); + Data_Get_Struct(self, notmuch_directory_t, dir); if (!FIXNUM_P(mtimev)) rb_raise(rb_eTypeError, "First argument not a fixnum"); - ret = notmuch_directory_set_mtime(dir->nm_dir, FIX2UINT(mtimev)); + ret = notmuch_directory_set_mtime(dir, FIX2UINT(mtimev)); notmuch_rb_status_raise(ret); + return Qtrue; } @@ -66,18 +84,14 @@ notmuch_rb_directory_set_mtime(VALUE self, VALUE mtimev) VALUE notmuch_rb_directory_get_child_files(VALUE self) { - notmuch_rb_directory_t *dir; - notmuch_rb_filenames_t *flist; - VALUE flistv; + notmuch_directory_t *dir; + notmuch_filenames_t *fnames; - Data_Get_Struct(self, notmuch_rb_directory_t, dir); + Data_Get_Struct(self, notmuch_directory_t, dir); - flistv = Data_Make_Struct(notmuch_rb_cFileNames, notmuch_rb_filenames_t, - notmuch_rb_filenames_mark, notmuch_rb_filenames_free, flist); - flist->dir = self; - flist->nm_flist = notmuch_directory_get_child_files(dir->nm_dir); + fnames = notmuch_directory_get_child_files(dir); - return flistv; + return Data_Wrap_Struct(notmuch_rb_cFileNames, NULL, NULL, fnames); } /* @@ -89,16 +103,12 @@ notmuch_rb_directory_get_child_files(VALUE self) VALUE notmuch_rb_directory_get_child_directories(VALUE self) { - notmuch_rb_directory_t *dir; - notmuch_rb_filenames_t *flist; - VALUE flistv; + notmuch_directory_t *dir; + notmuch_filenames_t *fnames; - Data_Get_Struct(self, notmuch_rb_directory_t, dir); + Data_Get_Struct(self, notmuch_directory_t, dir); - flistv = Data_Make_Struct(notmuch_rb_cFileNames, notmuch_rb_filenames_t, - notmuch_rb_filenames_mark, notmuch_rb_filenames_free, flist); - flist->dir = self; - flist->nm_flist = notmuch_directory_get_child_directories(dir->nm_dir); + fnames = notmuch_directory_get_child_directories(dir); - return flistv; + return Data_Wrap_Struct(notmuch_rb_cFileNames, NULL, NULL, fnames); } |