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

Function copy_if_not_alloced

sql/sql_string.cc:787–802  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

785
786
787String *copy_if_not_alloced(String *to,String *from,uint32 from_length)
788{
789 if (from->Alloced_length >= from_length)
790 return from;
791 if ((from->alloced && (from->Alloced_length != 0)) || !to || from == to)
792 {
793 (void) from->realloc(from_length);
794 return from;
795 }
796 if (to->realloc(from_length))
797 return from; // Actually an error
798 if ((to->str_length=min(from->str_length,from_length)))
799 memcpy(to->Ptr,from->Ptr,to->str_length);
800 to->str_charset=from->str_charset;
801 return to;
802}
803
804
805/****************************************************************************

Callers 1

val_strMethod · 0.85

Calls 2

minFunction · 0.85
reallocMethod · 0.45

Tested by

no test coverage detected