Changeset 2171
- Timestamp:
- 09/22/08 00:08:00 (4 months ago)
- Files:
-
- libswish3/trunk/src/libswish3/libswish3.h (modified) (2 diffs)
- libswish3/trunk/src/libswish3/mem.c (modified) (2 diffs)
- libswish3/trunk/src/libswish3/swish.c (modified) (5 diffs)
- libswish3/trunk/src/libswish3/tokenizer.c (modified) (4 diffs)
- libswish3/trunk/src/swish_lint.c (modified) (2 diffs)
- libswish3/trunk/src/swish_tokenize.c (modified) (1 diff)
- libswish3/trunk/src/utf8test.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
libswish3/trunk/src/libswish3/libswish3.h
r2169 r2171 287 287 unsigned int len; 288 288 int ref_cnt; 289 swish_TokenList *list; // the parent list290 289 }; 291 290 … … 421 420 void swish_xfree( void *ptr ); 422 421 void swish_mem_debug(); 422 long int swish_get_memcount(); 423 423 xmlChar * swish_xstrdup( const xmlChar * ptr ); 424 424 xmlChar * swish_xstrndup( const xmlChar * ptr, int len ); libswish3/trunk/src/libswish3/mem.c
r2133 r2171 38 38 { 39 39 memcount = 0; 40 } 40 41 42 long int 43 swish_get_memcount( 44 ) 45 { 46 return memcount; 41 47 } 42 48 … … 136 142 if (memcount > 0) 137 143 SWISH_WARN 138 (" memory error:%ld more swish_xmalloc()s or swish_xstrdup()s than swish_xfree()s",144 ("%ld more swish_xmalloc()s or swish_xstrdup()s than swish_xfree()s", 139 145 memcount); 140 146 141 147 if (memcount < 0) 142 SWISH_WARN(" memory error:too many swish_xfree()s %d", memcount);148 SWISH_WARN("too many swish_xfree()s %d", memcount); 143 149 } libswish3/trunk/src/libswish3/swish.c
r2170 r2171 31 31 { 32 32 swish_3 *s3; 33 swish_init();34 33 s3 = swish_xmalloc(sizeof(swish_3)); 35 34 s3->ref_cnt = 0; … … 54 53 swish_3 *s3 55 54 ) 56 { 57 boolean children_are_freed; 58 59 children_are_freed = 0; 55 { 60 56 s3->parser->ref_cnt--; 61 57 if (s3->parser->ref_cnt < 1) { 62 58 swish_free_parser(s3->parser); 63 children_are_freed++;64 59 } 65 60 … … 67 62 if (s3->analyzer->ref_cnt < 1) { 68 63 swish_free_analyzer(s3->analyzer); 69 children_are_freed++;70 64 } 71 65 … … 73 67 if (s3->config->ref_cnt < 1) { 74 68 swish_free_config(s3->config); 75 children_are_freed++;76 69 } 77 70 … … 80 73 } 81 74 swish_xfree(s3); 82 83 if (children_are_freed == 3) {84 swish_mem_debug();85 }86 75 } 87 76 77 /* MUST call this before instantiating any swish_3 objects */ 88 78 void 89 79 swish_init( libswish3/trunk/src/libswish3/tokenizer.c
r2169 r2171 441 441 t->len = 0; 442 442 t->ref_cnt = 0; 443 t->list = NULL;444 443 return t; 445 444 } … … 453 452 SWISH_WARN("freeing Token with ref_cnt != 0 (%d)", t->ref_cnt); 454 453 } 455 454 455 if (SWISH_DEBUG & SWISH_DEBUG_MEMORY) { 456 SWISH_DEBUG_MSG("freeing Token %d with MetaName ref_cnt %d", 457 t, t->meta->ref_cnt); 458 } 459 456 460 t->meta->ref_cnt--; 457 if (t->meta->ref_cnt == 0) 461 if (t->meta->ref_cnt == 0) { 462 if (SWISH_DEBUG & SWISH_DEBUG_MEMORY) { 463 SWISH_DEBUG_MSG("Token's MetaName ref_cnt == 0 ... freeing MetaName"); 464 } 458 465 swish_free_metaname(t->meta); 459 460 if (t->list != NULL) { 461 t->list->ref_cnt--; 462 } 463 466 } 467 464 468 swish_xfree(t); 465 469 } … … 521 525 } 522 526 527 if (SWISH_DEBUG & SWISH_DEBUG_MEMORY) { 528 SWISH_DEBUG_MSG( 529 "freeing TokenIterator %d with TokenList ref_cnt %d and s3 ref_cnt %d", 530 it, it->tl->ref_cnt, it->s3->ref_cnt); 531 } 532 523 533 it->s3->ref_cnt--; 524 534 … … 544 554 545 555 t = it->tl->tokens[it->pos++]; 546 t->list = it->tl;547 t->list->ref_cnt++;548 556 return t; 549 557 } libswish3/trunk/src/swish_lint.c
r2167 r2171 156 156 swish_3 *s3; 157 157 158 swish_init(); // always call first 158 159 option_index = 0; 159 160 files = 0; … … 249 250 250 251 swish_free_swish3(s3); 252 swish_mem_debug(); 251 253 252 254 return (0); libswish3/trunk/src/swish_tokenize.c
r2162 r2171 75 75 swish_3 *s3; 76 76 77 swish_init(); // always call first 77 78 meta = (xmlChar *)SWISH_DEFAULT_METANAME; 78 79 option_index = 0; libswish3/trunk/src/utf8test.c
r2140 r2171 71 71 loop = 1; 72 72 73 swish_ verify_utf8_locale();73 swish_init(); // always call first 74 74 75 75 while ((ch = getopt_long(argc, argv, "d:f:h", longopts, &option_index)) != -1) {
