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

Method base_list

sql/sql_list.cc:38–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36
37
38base_list::base_list(const base_list &rhs, MEM_ROOT *mem_root)
39{
40 if (rhs.elements)
41 {
42 /*
43 It's okay to allocate an array of nodes at once: we never
44 call a destructor for list_node objects anyway.
45 */
46 first= (list_node*) alloc_root(mem_root,
47 sizeof(list_node) * rhs.elements);
48 if (first)
49 {
50 elements= rhs.elements;
51 list_node *dst= first;
52 list_node *src= rhs.first;
53 for (; dst < first + elements - 1; dst++, src= src->next)
54 {
55 dst->info= src->info;
56 dst->next= dst + 1;
57 }
58 /* Copy the last node */
59 dst->info= src->info;
60 dst->next= &end_of_list;
61 /* Setup 'last' member */
62 last= &dst->next;
63 return;
64 }
65 }
66 elements= 0;
67 first= &end_of_list;
68 last= &first;
69}

Callers

nothing calls this directly

Calls 1

alloc_rootFunction · 0.85

Tested by

no test coverage detected