Shrink the buffer, but only if it is allocated on the heap.
| 325 | |
| 326 | // Shrink the buffer, but only if it is allocated on the heap. |
| 327 | inline void shrink(uint32 arg_length) |
| 328 | { |
| 329 | if (!is_alloced()) |
| 330 | return; |
| 331 | if (arg_length < Alloced_length) |
| 332 | { |
| 333 | char *new_ptr; |
| 334 | if (!(new_ptr=(char*) my_realloc(Ptr,arg_length,MYF(0)))) |
| 335 | { |
| 336 | Alloced_length = 0; |
| 337 | real_alloc(arg_length); |
| 338 | } |
| 339 | else |
| 340 | { |
| 341 | Ptr=new_ptr; |
| 342 | Alloced_length=arg_length; |
| 343 | } |
| 344 | } |
| 345 | } |
| 346 | bool is_alloced() const { return alloced; } |
| 347 | inline String& operator = (const String &s) |
| 348 | { |
no test coverage detected