ext/trie/trie.c in tyler-trie-0.2.2 vs ext/trie/trie.c in tyler-trie-0.2.3

- old
+ new

@@ -5,10 +5,11 @@ #include <string.h> VALUE cTrie, cTrieNode; static TrieChar* stringToTrieChar(VALUE string) { + StringValue(string); return (TrieChar*) RSTRING(string)->ptr; } static void trie_free(SBTrie *sb_trie) { if(sb_trie) @@ -146,10 +147,13 @@ } } } static VALUE trie_children(VALUE self, VALUE prefix) { + if(NIL_P(prefix)) + return rb_ary_new(); + SBTrie *sb_trie; Data_Get_Struct(self, SBTrie, sb_trie); const TrieChar *sb_prefix = stringToTrieChar(prefix); @@ -202,9 +206,12 @@ } } } static VALUE trie_children_with_values(VALUE self, VALUE prefix) { + if(NIL_P(prefix)) + return rb_ary_new(); + SBTrie *sb_trie; Data_Get_Struct(self, SBTrie, sb_trie); const TrieChar *sb_prefix = stringToTrieChar(prefix);