diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-09-02 13:38:01 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-09-02 13:38:01 -0700 |
commit | 531c7ee4fade42ff115ba9df9ca1ca7d7ad631d6 (patch) | |
tree | 221db6480087f2231ad3622d8fb1995f9c8c1511 /ext/rpatricia/rpatricia.c | |
parent | 916b7be928c1a7c6b4aa8ab2f58987487a78777e (diff) | |
download | rpatricia-531c7ee4fade42ff115ba9df9ca1ca7d7ad631d6.tar.gz |
Patricia#{clear,destroy} clears the tree
While the GC can take care of this, this is still useful if one wishes to reuse the same object.
Diffstat (limited to 'ext/rpatricia/rpatricia.c')
-rw-r--r-- | ext/rpatricia/rpatricia.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/ext/rpatricia/rpatricia.c b/ext/rpatricia/rpatricia.c index f9564d2..866572c 100644 --- a/ext/rpatricia/rpatricia.c +++ b/ext/rpatricia/rpatricia.c @@ -12,13 +12,15 @@ static VALUE cPatricia, cNode; static void dummy(void) {} -/* - * this method only exists for backwards compatibility, we now rely - * on the GC to do all the dirty work of freeing node data for us - */ static VALUE p_destroy (VALUE self) { + patricia_tree_t *tree; + + Data_Get_Struct(self, patricia_tree_t, tree); + Clear_Patricia(tree, dummy); + tree->head = NULL; /* Clear_Patricia() should do this, actually */ + return Qtrue; } |