Changeset 2160
- Timestamp:
- 09/20/08 01:05:24 (4 months ago)
- Files:
-
- libswish3/trunk/src/libswish3/tokenizer.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
libswish3/trunk/src/libswish3/tokenizer.c
r2155 r2160 343 343 tl->n--; 344 344 tl->tokens[tl->n]->ref_cnt--; 345 swish_free_token(tl->tokens[tl->n]); 345 if (tl->tokens[tl->n]->ref_cnt < 1) 346 swish_free_token(tl->tokens[tl->n]); 346 347 } 347 348 … … 418 419 xmlChar * 419 420 swish_get_token_value( 420 swish_TokenList *tl,421 421 swish_Token *t 422 422 ) 423 423 { 424 424 /* SWISH_DEBUG_MSG("get token value: '%s' %d, %d", xmlBufferContent(tl->buf), t->start_byte, t->len); */ 425 return xmlStrsub(xmlBufferContent(t l->buf), t->start_byte, t->len);425 return xmlStrsub(xmlBufferContent(t->list->buf), t->start_byte, t->len); 426 426 } 427 427 … … 439 439 t->len = 0; 440 440 t->ref_cnt = 0; 441 t->list = NULL; 441 442 return t; 442 443 } … … 455 456 456 457 t->meta->ref_cnt--; 458 if (t->meta->ref_cnt == 0) 459 swish_free_metaname(t->meta); 460 461 if (t->list != NULL) { 462 t->list->ref_cnt--; 463 } 457 464 458 465 swish_xfree(t); … … 487 494 */ 488 495 while ((t = swish_next_token(it)) != NULL) { 489 t->value = swish_get_token_value( it->tl,t);496 t->value = swish_get_token_value(t); 490 497 swish_debug_token(t); 491 498 } … … 518 525 } 519 526 it->config->ref_cnt--; 527 if (it->config->ref_cnt == 0) 528 swish_free_config(it->config); 529 520 530 it->tl->ref_cnt--; 531 if (it->tl->ref_cnt == 0) 532 swish_free_token_list(it->tl); 533 521 534 swish_xfree(it); 522 535 } … … 527 540 ) 528 541 { 542 swish_Token *t; 543 t = NULL; 544 529 545 /* SWISH_DEBUG_MSG("next_token: %d %d", it->pos, it->tl->n); */ 530 546 if (it->pos >= it->tl->n) 531 547 return NULL; 532 548 533 return it->tl->tokens[it->pos++]; 549 550 t = it->tl->tokens[it->pos++]; 551 t->list = it->tl; 552 t->list->ref_cnt++; 553 return t; 534 554 } 535 555 … … 539 559 swish_3 *s3, 540 560 xmlChar *buf, 541 ... 542 ) 543 { 544 swish_TokenList *tl; 545 swish_MetaName *meta; 546 xmlChar *context; 547 548 va_list args; 549 550 va_start(args, buf); 551 tl = va_arg(args, swish_TokenList * 552 ); 553 meta = va_arg(args, swish_MetaName * 554 ); 555 context = va_arg(args, xmlChar * 556 ); 557 558 va_end(args); 559 561 swish_TokenList *tl, 562 swish_MetaName *meta, 563 xmlChar *context 564 ) 565 { 560 566 if (swish_is_ascii(buf)) { 561 567 return swish_tokenize3_ascii(s3, buf, tl, meta, context);
