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

Function strmake

strings/strmake.c:31–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29#include "m_string.h"
30
31char *strmake(register char *dst, register const char *src, size_t length)
32{
33#ifdef EXTRA_DEBUG
34 /*
35 'length' is the maximum length of the string; the buffer needs
36 to be one character larger to accomodate the terminating '\0'.
37 This is easy to get wrong, so we make sure we write to the
38 entire length of the buffer to identify incorrect buffer-sizes.
39 We only initialise the "unused" part of the buffer here, a) for
40 efficiency, and b) because dst==src is allowed, so initialising
41 the entire buffer would overwrite the source-string. Also, we
42 write a character rather than '\0' as this makes spotting these
43 problems in the results easier.
44 */
45 uint n= 0;
46 while (n < length && src[n++]);
47 memset(dst + n, (int) 'Z', length - n + 1);
48#endif
49
50 while (length--)
51 if (! (*dst++ = *src++))
52 return dst-1;
53 *dst=0;
54 return dst;
55}

Callers 15

cli_safe_readFunction · 0.85
send_change_user_packetFunction · 0.85
send_client_reply_packetFunction · 0.85
client.cFile · 0.85
extract_date_timeFunction · 0.85
init_common_variablesFunction · 0.85
mysql_init_variablesFunction · 0.85
fix_pathsFunction · 0.85
handle_conditionMethod · 0.85
make_log_nameFunction · 0.85
generate_nameMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected