MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / shrink

Method shrink

sql/sql_string.h:327–345  ·  view source on GitHub ↗

Shrink the buffer, but only if it is allocated on the heap.

Source from the content-addressed store, hash-verified

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 {

Callers 1

alloc_queryFunction · 0.80

Calls 1

my_reallocFunction · 0.85

Tested by

no test coverage detected