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

Function date_time_format_copy

sql/sql_time.cc:952–975  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

950*/
951
952DATE_TIME_FORMAT *date_time_format_copy(THD *thd, DATE_TIME_FORMAT *format)
953{
954 DATE_TIME_FORMAT *new_format;
955 ulong length= sizeof(*format) + format->format.length + 1;
956
957 if (thd)
958 new_format= (DATE_TIME_FORMAT *) thd->alloc(length);
959 else
960 new_format= (DATE_TIME_FORMAT *) my_malloc(length, MYF(MY_WME));
961 if (new_format)
962 {
963 /* Put format string after current pos */
964 new_format->format.str= (char*) (new_format+1);
965 memcpy((char*) new_format->positions, (char*) format->positions,
966 sizeof(format->positions));
967 new_format->time_separator= format->time_separator;
968 /* We make the string null terminated for easy printf in SHOW VARIABLES */
969 memcpy((char*) new_format->format.str, format->format.str,
970 format->format.length);
971 new_format->format.str[format->format.length]= 0;
972 new_format->format.length= format->format.length;
973 }
974 return new_format;
975}
976
977
978KNOWN_DATE_TIME_FORMAT known_date_time_formats[6]=

Callers 1

date_time_format_makeFunction · 0.85

Calls 2

my_mallocFunction · 0.85
allocMethod · 0.45

Tested by

no test coverage detected