| 719 | |
| 720 | |
| 721 | bool Binary_string::replace(uint32 offset, uint32 arg_length, |
| 722 | const char *to, uint32 to_length) |
| 723 | { |
| 724 | long diff = (long) to_length-(long) arg_length; |
| 725 | if (offset+arg_length <= str_length) |
| 726 | { |
| 727 | if (diff < 0) |
| 728 | { |
| 729 | if (to_length) |
| 730 | memcpy(Ptr+offset,to,to_length); |
| 731 | bmove(Ptr+offset+to_length,Ptr+offset+arg_length, |
| 732 | str_length-offset-arg_length); |
| 733 | } |
| 734 | else |
| 735 | { |
| 736 | if (diff) |
| 737 | { |
| 738 | if (realloc_with_extra_if_needed(str_length+(uint32) diff)) |
| 739 | return TRUE; |
| 740 | bmove_upp((uchar*) Ptr+str_length+diff, (uchar*) Ptr+str_length, |
| 741 | str_length-offset-arg_length); |
| 742 | } |
| 743 | if (to_length) |
| 744 | memcpy(Ptr+offset,to,to_length); |
| 745 | } |
| 746 | str_length+=(uint32) diff; |
| 747 | } |
| 748 | return FALSE; |
| 749 | } |
| 750 | |
| 751 | |
| 752 | // added by Holyfoot for "geometry" needs |