| 677 | {} |
| 678 | |
| 679 | int Alloc(int len) |
| 680 | { |
| 681 | if(len<len_) |
| 682 | { |
| 683 | return -1; |
| 684 | } |
| 685 | |
| 686 | if(len==0) |
| 687 | { |
| 688 | len = BUF_ALIGNMENT_SIZE; |
| 689 | } |
| 690 | if(len_==len) |
| 691 | { |
| 692 | return 0; |
| 693 | } |
| 694 | |
| 695 | len_ = BUF_ALIGN_SIZE(len); |
| 696 | if(len_==0) |
| 697 | { |
| 698 | len_ = BUF_DEFAULT_SIZE; |
| 699 | } |
| 700 | len_watermark_ = len_-BUF_ALIGNMENT_SIZE; |
| 701 | char* tmp = (char*)realloc(buf_, len_); |
| 702 | if(tmp==NULL) |
| 703 | { |
| 704 | return -2; |
| 705 | } |
| 706 | |
| 707 | buf_ = tmp; |
| 708 | return 0; |
| 709 | } |
| 710 | |
| 711 | void reset() |
| 712 | { |
no test coverage detected