Changeset 2030
- Timestamp:
- 02/25/08 21:58:22 (3 months ago)
- Files:
-
- libswish3/trunk/bindings/perl/XS/Analyzer.xs (modified) (1 diff)
- libswish3/trunk/bindings/perl/XS/Config.xs (modified) (1 diff)
- libswish3/trunk/bindings/perl/XS/Data.xs (modified) (3 diffs)
- libswish3/trunk/bindings/perl/lib/SWISH/3.pm (modified) (1 diff)
- libswish3/trunk/bindings/perl/t/07-refcnt.t (modified) (1 diff)
- libswish3/trunk/bindings/perl/t/11get_set_parser.t (modified) (1 diff)
- libswish3/trunk/bindings/perl/t/12-stash.t (modified) (1 diff)
- libswish3/trunk/bindings/perl/xs_helpers.c (modified) (6 diffs)
- libswish3/trunk/src/libswish3/docinfo.c (modified) (2 diffs)
- libswish3/trunk/src/libswish3/libswish3.h (modified) (1 diff)
- libswish3/trunk/src/libswish3/parser.c (modified) (9 diffs)
- libswish3/trunk/src/libswish3/words.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
libswish3/trunk/bindings/perl/XS/Analyzer.xs
r2029 r2030 135 135 context 136 136 ); 137 138 RETVAL->ref_cnt++; 139 137 140 138 /* TODO do we need to worry about free()ing metaname and context ?? */ 141 139 libswish3/trunk/bindings/perl/XS/Config.xs
r2029 r2030 8 8 9 9 CODE: 10 RETVAL = sp_new_config(); 10 RETVAL = swish_init_config(); 11 RETVAL->ref_cnt++; 12 RETVAL->stash = sp_Stash_new(); 11 13 12 14 OUTPUT: libswish3/trunk/bindings/perl/XS/Data.xs
r2029 r2030 14 14 CODE: 15 15 self->s3->ref_cnt++; 16 class = sp_ hvref_fetch_as_char((SV*)self->s3->stash, SELF_CLASS_KEY);16 class = sp_Stash_get_char((SV*)self->s3->stash, SELF_CLASS_KEY); 17 17 warn("s3 class = %s\n", class); 18 18 RETVAL = sp_bless_ptr( class, (IV)self->s3 ); … … 33 33 34 34 CODE: 35 CLASS = sp_ hvref_fetch_as_char(self->s3->stash, CONFIG_CLASS_KEY);35 CLASS = sp_Stash_get_char(self->s3->stash, CONFIG_CLASS_KEY); 36 36 self->s3->config->ref_cnt++; 37 37 RETVAL = self->s3->config; … … 122 122 # MUST increment refcnt 2x so that SWISH::3::WordList::DESTROY 123 123 # does not free it. 124 self->wordlist->ref_cnt += 2; 124 //self->wordlist->ref_cnt += 2; 125 self->wordlist->ref_cnt++; 125 126 RETVAL = self->wordlist; 126 127 libswish3/trunk/bindings/perl/lib/SWISH/3.pm
r2029 r2030 131 131 132 132 print "WordList\n"; 133 while ( my $swishword = $data->wordlist->next ) { 133 my $wordlist = $data->wordlist; 134 while ( my $swishword = $wordlist->next ) { 134 135 print '-' x 50, "\n"; 135 136 for my $w (SWISH_WORD_FIELDS) { libswish3/trunk/bindings/perl/t/07-refcnt.t
r2029 r2030 21 21 # avoid spurious mem error from libswish3 22 22 # just because of order of Perl ref cleanup 23 #undef $analyzer;23 undef $analyzer; 24 24 libswish3/trunk/bindings/perl/t/11get_set_parser.t
r2029 r2030 44 44 #undef $conf1; 45 45 #undef $config; 46 #undef $s3;46 undef $s3; 47 47 libswish3/trunk/bindings/perl/t/12-stash.t
r2029 r2030 12 12 ok(my $s3 = SWISH::3->new( config_class => 'MyConfig' ), "new s3"); 13 13 ok(my $conf = $s3->config, "get config"); 14 undef $conf; 14 15 undef $s3; 15 16 diag("s3 == undef"); libswish3/trunk/bindings/perl/xs_helpers.c
r2029 r2030 26 26 static void sp_describe_object( SV* object ); 27 27 static IV sp_extract_ptr( SV* object ); 28 static SV* sp_accessor( SV* object, char* name );29 28 static void sp_store_xml2_pair_in_perl_hash( xmlChar* val, HV* perl_hash, xmlChar* key ); 30 29 static HV* sp_xml2_hash_to_perl_hash( xmlHashTablePtr xml2_hash ); … … 40 39 static void sp_debug_token( swish_Token *token ); 41 40 static HV* sp_get_config_subconfig( swish_Config* config, const char* key ); 42 static swish_Config* sp_new_config(); 43 static swish_Analyzer* sp_new_analyzer(); 44 45 /* implements nearly all methods for SWISH::3::Stash, a private class */ 41 42 /* implement nearly all methods for SWISH::3::Stash, a private class */ 46 43 47 44 static SV* sp_Stash_new(); … … 385 382 } 386 383 387 388 /* fetch a hash value from an object (i.e. a generic accessor) */389 static SV*390 sp_accessor( SV* object, char* name )391 {392 dTHX;393 char* class = sp_get_objects_class( object );394 //warn("looking for %s in %s\n", name, class);395 HV* hash = sp_extract_hash( object );396 SV* sv = sp_hv_fetch( hash, (const char*)name );397 398 if (!sv)399 croak("no %s in %s object!", name, class);400 401 return sv;402 }403 404 384 static void 405 385 sp_hv_replace( HV *hash, char *key, SV *value ) … … 541 521 //sp_describe_object(s3->stash); 542 522 543 handler = sp_ hvref_fetch((SV*)s3->stash, HANDLER_KEY);523 handler = sp_Stash_get(s3->stash, HANDLER_KEY); 544 524 545 525 //warn("got handler and s3"); 546 526 547 data_class = sp_ hvref_fetch_as_char((SV*)s3->stash, DATA_CLASS_KEY);527 data_class = sp_Stash_get_char(s3->stash, DATA_CLASS_KEY); 548 528 549 529 //warn("data_class = %s", data_class); … … 640 620 641 621 list = swish_init_wordlist(); 622 list->ref_cnt++; 642 623 num_code_points = 0; 643 624 … … 758 739 } 759 740 760 static swish_Config*761 sp_new_config()762 {763 HV* stash;764 swish_Config* config;765 766 stash = newHV();767 config = swish_init_config();768 config->ref_cnt++;769 config->stash = sp_Stash_new();770 771 return config;772 }libswish3/trunk/src/libswish3/docinfo.c
r2027 r2030 43 43 44 44 swish_DocInfo *docinfo = swish_xmalloc( sizeof(swish_DocInfo) ); 45 docinfo->ref_cnt = 0; 45 46 docinfo->nwords = 0; 46 47 docinfo->mtime = 0; … … 72 73 swish_debug_docinfo( ptr ); 73 74 75 76 if (ptr->ref_cnt != 0) { 77 SWISH_WARN("docinfo ref_cnt != 0: %d", ptr->ref_cnt); 78 } 74 79 75 80 ptr->nwords = 0; /* why is this required? */ libswish3/trunk/src/libswish3/libswish3.h
r2027 r2030 243 243 xmlChar * parser; 244 244 xmlChar * update; 245 int ref_cnt; 245 246 }; 246 247 libswish3/trunk/src/libswish3/parser.c
r2028 r2030 749 749 ptr->tag = NULL; 750 750 ptr->wordlist = swish_init_wordlist(); 751 ptr->wordlist->ref_cnt++; 751 752 ptr->properties = swish_init_nb(s3->config, (xmlChar*)SWISH_PROP); 753 ptr->properties->ref_cnt++; 752 754 ptr->metanames = swish_init_nb(s3->config, (xmlChar*)SWISH_META); 755 ptr->metanames->ref_cnt++; 753 756 754 757 /* prime the stacks */ … … 842 845 SWISH_DEBUG_MSG("freeing swish_ParserData properties"); 843 846 847 ptr->properties->ref_cnt--; 844 848 swish_free_nb(ptr->properties); 845 849 … … 847 851 SWISH_DEBUG_MSG("freeing swish_ParserData metanames"); 848 852 853 ptr->metanames->ref_cnt--; 849 854 swish_free_nb(ptr->metanames); 850 855 … … 894 899 SWISH_DEBUG_MSG("free swish_ParserData wordList"); 895 900 901 ptr->wordlist->ref_cnt--; 896 902 swish_free_wordlist(ptr->wordlist); 897 903 } … … 903 909 SWISH_DEBUG_MSG("free swish_ParserData docinfo"); 904 910 911 ptr->docinfo->ref_cnt--; 905 912 swish_free_docinfo(ptr->docinfo); 906 913 … … 983 990 984 991 swish_DocInfo *info = swish_init_docinfo(); 992 info->ref_cnt++; 985 993 986 994 if (SWISH_DEBUG > 5) … … 1251 1259 /* blank line indicates body */ 1252 1260 curTime = swish_time_elapsed(); 1253 parser_data = init_parser_data(s3);1261 parser_data = init_parser_data(s3); 1254 1262 head = buf_to_head( (xmlChar*)xmlBufferContent(head_buf) ); 1255 1263 parser_data->docinfo = head_to_docinfo(head); … … 1435 1443 swish_ParserData *parser_data = init_parser_data(s3); 1436 1444 parser_data->docinfo = swish_init_docinfo(); 1445 parser_data->docinfo->ref_cnt++; 1437 1446 1438 1447 if (!swish_docinfo_from_filesystem(filename, parser_data->docinfo, parser_data)) … … 1780 1789 if (tmplist->nwords == 0) 1781 1790 { 1791 tmplist->ref_cnt--; 1782 1792 swish_free_wordlist(tmplist); 1783 1793 return; libswish3/trunk/src/libswish3/words.c
r2028 r2030 146 146 147 147 swish_WordList *list = swish_init_wordlist(); 148 148 list->ref_cnt++; 149 149 150 150 return list; … … 283 283 int byte_count = 0; 284 284 swish_WordList *list = swish_init_wordlist(); 285 list->ref_cnt++; 285 286 xmlChar * utf8_str; 286 287 … … 504 505 char c, nextc, in_word; 505 506 int i, w, wl, byte_count; 506 swish_WordList * list = swish_init_wordlist(); 507 xmlChar * word = swish_xmalloc(sizeof(xmlChar*) * analyzer->maxwordlen); 507 swish_WordList * list; 508 xmlChar * word; 509 list = swish_init_wordlist(); 510 list->ref_cnt++; 511 word = swish_xmalloc(sizeof(xmlChar*) * analyzer->maxwordlen); 508 512 509 513 if (!initialized)
