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

Function dynstr_set

mysys/string.c:50–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48
49
50my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str)
51{
52 uint length=0;
53 DBUG_ENTER("dynstr_set");
54
55 if (init_str && (length= (uint) strlen(init_str)+1) > str->max_length)
56 {
57 str->max_length=((length+str->alloc_increment-1)/str->alloc_increment)*
58 str->alloc_increment;
59 if (!str->max_length)
60 str->max_length=str->alloc_increment;
61 if (!(str->str=(char*) my_realloc(str->str,str->max_length,MYF(MY_WME))))
62 DBUG_RETURN(TRUE);
63 }
64 if (init_str)
65 {
66 str->length=length-1;
67 memcpy(str->str,init_str,length);
68 }
69 else
70 str->length=0;
71 DBUG_RETURN(FALSE);
72}
73
74
75my_bool dynstr_realloc(DYNAMIC_STRING *str, size_t additional_size)

Callers

nothing calls this directly

Calls 1

my_reallocFunction · 0.85

Tested by

no test coverage detected