Mercurial > pt1.oyama
comparison src/recpt1.c @ 144:bf96eac4dbb1
Changed to a variable length buffer of splitbuf_t
author | Naoya OYAMA <naoya.oyama@gmail.com> |
---|---|
date | Wed, 01 Aug 2012 23:23:24 +0900 |
parents | d65c15276b5e |
children | 066f33b2213a |
comparison
equal
deleted
inserted
replaced
143:e72dd5e8d53f | 144:bf96eac4dbb1 |
---|---|
416 int split_select_finish = TSS_ERROR; | 416 int split_select_finish = TSS_ERROR; |
417 | 417 |
418 buf.size = 0; | 418 buf.size = 0; |
419 buf.data = NULL; | 419 buf.data = NULL; |
420 splitbuf.size = 0; | 420 splitbuf.size = 0; |
421 splitbuf.buffer_length = 0; | |
422 splitbuf.buffer = NULL; | |
421 | 423 |
422 if(wfd == -1) | 424 if(wfd == -1) |
423 fileless = TRUE; | 425 fileless = TRUE; |
424 | 426 |
425 if(use_udp) { | 427 if(use_udp) { |
452 } | 454 } |
453 | 455 |
454 | 456 |
455 if(use_splitter) { | 457 if(use_splitter) { |
456 splitbuf.size = 0; | 458 splitbuf.size = 0; |
459 if(splitbuf.buffer_length < buf.size && buf.size > 0) { | |
460 splitbuf.buffer = realloc(splitbuf.buffer, buf.size); | |
461 if(NULL == splitbuf.buffer) { | |
462 fprintf(stderr, "splitbuf.buffer realloc failed\n"); | |
463 use_splitter = FALSE; | |
464 goto fin; | |
465 } | |
466 splitbuf.buffer_length = buf.size; | |
467 } | |
457 | 468 |
458 while(buf.size) { | 469 while(buf.size) { |
459 /* $BJ,N%BP>](BPID$B$NCj=P(B */ | 470 /* $BJ,N%BP>](BPID$B$NCj=P(B */ |
460 if(split_select_finish != TSS_SUCCESS) { | 471 if(split_select_finish != TSS_SUCCESS) { |
461 split_select_finish = split_select(splitter, &buf); | 472 split_select_finish = split_select(splitter, &buf); |
606 if(wc < 0) { | 617 if(wc < 0) { |
607 if(errno == EPIPE) | 618 if(errno == EPIPE) |
608 pthread_kill(signal_thread, SIGPIPE); | 619 pthread_kill(signal_thread, SIGPIPE); |
609 } | 620 } |
610 } | 621 } |
622 if(use_splitter) { | |
623 free(splitbuf.buffer); | |
624 splitbuf.buffer = NULL; | |
625 splitbuf.buffer_length = 0; | |
626 } | |
611 | 627 |
612 break; | 628 break; |
613 } | 629 } |
614 } | 630 } |
615 | 631 |