MySQL  8.0.24
Source Code Documentation
prealloced_array.h
Go to the documentation of this file.
1 /* Copyright (c) 2013, 2021, Oracle and/or its affiliates.
2 
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License, version 2.0,
5  as published by the Free Software Foundation.
6 
7  This program is also distributed with certain software (including
8  but not limited to OpenSSL) that is licensed under separate terms,
9  as designated in a particular file or component or in included license
10  documentation. The authors of MySQL hereby grant you an additional
11  permission to link the program and your derivative works with the
12  separately licensed software that they have included with MySQL.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License, version 2.0, for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22 
23 #ifndef PREALLOCED_ARRAY_INCLUDED
24 #define PREALLOCED_ARRAY_INCLUDED
25 
26 /**
27  @file include/prealloced_array.h
28 */
29 
30 #include <assert.h>
31 #include <stddef.h>
32 #include <algorithm>
33 #include <new>
34 #include <type_traits>
35 #include <utility>
36 
37 #include "my_compiler.h"
38 
39 #include "my_inttypes.h"
40 #include "my_sys.h"
41 #include "mysql/psi/psi_memory.h"
43 
44 /**
45  A typesafe replacement for DYNAMIC_ARRAY. We do our own memory management,
46  and pre-allocate space for a number of elements. The purpose is to
47  pre-allocate enough elements to cover normal use cases, thus saving
48  malloc()/free() overhead.
49  If we run out of space, we use malloc to allocate more space.
50 
51  The interface is chosen to be similar to std::vector.
52  We keep the std::vector property that storage is contiguous.
53 
54  @remark
55  Unlike DYNAMIC_ARRAY, elements are properly copied
56  (rather than memcpy()d) if the underlying array needs to be expanded.
57 
58  @remark
59  Depending on Has_trivial_destructor, we destroy objects which are
60  removed from the array (including when the array object itself is destroyed).
61 
62  @tparam Element_type The type of the elements of the container.
63  Elements must be copyable or movable.
64  @tparam Prealloc Number of elements to pre-allocate.
65  */
66 template <typename Element_type, size_t Prealloc>
68  /**
69  Is Element_type trivially destructible? If it is, we don't destroy
70  elements when they are removed from the array or when the array is
71  destroyed.
72  */
73  static constexpr bool Has_trivial_destructor =
75 
76  /**
77  Casts the raw buffer to the proper Element_type.
78  We use a raw buffer rather than Element_type[] in order to avoid having
79  CTORs/DTORs invoked by the C++ runtime.
80  */
81  Element_type *cast_rawbuff() {
82  return static_cast<Element_type *>(static_cast<void *>(m_buff));
83  }
84 
85  public:
86  /// Initial capacity of the array.
87  static const size_t initial_capacity = Prealloc;
88 
89  /// Standard typedefs.
90  typedef Element_type value_type;
91  typedef size_t size_type;
92  typedef ptrdiff_t difference_type;
93 
94  typedef Element_type *iterator;
95  typedef const Element_type *const_iterator;
96 
97  explicit Prealloced_array(PSI_memory_key psi_key)
98  : m_size(0),
99  m_capacity(Prealloc),
101  m_psi_key(psi_key) {
102  static_assert(Prealloc != 0, "We do not want a zero-size array.");
103  }
104 
105  /**
106  Initializes (parts of) the array with default values.
107  Using 'Prealloc' for initial_size makes this similar to a raw C array.
108  */
109  Prealloced_array(PSI_memory_key psi_key, size_t initial_size)
110  : m_size(0),
111  m_capacity(Prealloc),
113  m_psi_key(psi_key) {
114  static_assert(Prealloc != 0, "We do not want a zero-size array.");
115 
116  if (initial_size > Prealloc) {
117  // We avoid using reserve() since it requires Element_type to be copyable.
118  void *mem =
119  my_malloc(m_psi_key, initial_size * element_size(), MYF(MY_WME));
120  if (!mem) return;
121  m_array_ptr = static_cast<Element_type *>(mem);
122  m_capacity = initial_size;
123  }
124  for (size_t ix = 0; ix < initial_size; ++ix) {
125  Element_type *p = &m_array_ptr[m_size++];
126  ::new (p) Element_type();
127  }
128  }
129 
130  /**
131  An object instance "owns" its array, so we do deep copy here.
132  */
134  : m_size(0),
135  m_capacity(Prealloc),
137  m_psi_key(that.m_psi_key) {
138  if (this->reserve(that.capacity())) return;
139  for (const Element_type *p = that.begin(); p != that.end(); ++p)
140  this->push_back(*p);
141  }
142 
144  : m_size(0),
145  m_capacity(Prealloc),
147  m_psi_key(that.m_psi_key) {
148  *this = std::move(that);
149  }
150 
151  /**
152  Range constructor.
153 
154  Constructs a container with as many elements as the range [first,last),
155  with each element constructed from its corresponding element in that range,
156  in the same order.
157  */
160  : m_size(0),
161  m_capacity(Prealloc),
163  m_psi_key(psi_key) {
164  if (this->reserve(last - first)) return;
165  for (; first != last; ++first) push_back(*first);
166  }
167 
168  Prealloced_array(std::initializer_list<Element_type> elems)
169  : Prealloced_array(PSI_NOT_INSTRUMENTED, elems.begin(), elems.end()) {}
170 
171  /**
172  Copies all the elements from 'that' into this container.
173  Any objects in this container are destroyed first.
174  */
176  this->clear();
177  if (this->reserve(that.capacity())) return *this;
178  for (const Element_type *p = that.begin(); p != that.end(); ++p)
179  this->push_back(*p);
180  return *this;
181  }
182 
184  this->clear();
185  if (that.m_array_ptr != that.cast_rawbuff()) {
187  // The array is on the heap, so we can just grab it.
188  m_array_ptr = that.m_array_ptr;
189  m_capacity = that.m_capacity;
190  m_size = that.m_size;
191  that.m_size = 0;
192  that.m_array_ptr = that.cast_rawbuff();
193  that.m_capacity = Prealloc;
194  } else {
195  // Move over each element.
196  if (this->reserve(that.capacity())) return *this;
197  for (Element_type *p = that.begin(); p != that.end(); ++p)
198  this->push_back(std::move(*p));
199  that.clear();
200  }
201  return *this;
202  }
203 
204  /**
205  Runs DTOR on all elements if needed.
206  Deallocates array if we exceeded the Preallocated amount.
207  */
209  if (!Has_trivial_destructor) {
210  clear();
211  }
213  }
214 
215  size_t capacity() const { return m_capacity; }
216  size_t element_size() const { return sizeof(Element_type); }
217  bool empty() const { return m_size == 0; }
218  size_t size() const { return m_size; }
219 
220  Element_type &at(size_t n) {
221  assert(n < size());
222  return m_array_ptr[n];
223  }
224 
225  const Element_type &at(size_t n) const {
226  assert(n < size());
227  return m_array_ptr[n];
228  }
229 
230  Element_type &operator[](size_t n) { return at(n); }
231  const Element_type &operator[](size_t n) const { return at(n); }
232 
233  Element_type &back() { return at(size() - 1); }
234  const Element_type &back() const { return at(size() - 1); }
235 
236  Element_type &front() { return at(0); }
237  const Element_type &front() const { return at(0); }
238 
239  /**
240  begin : Returns a pointer to the first element in the array.
241  end : Returns a pointer to the past-the-end element in the array.
242  */
243  iterator begin() { return m_array_ptr; }
244  iterator end() { return m_array_ptr + size(); }
245  const_iterator begin() const { return m_array_ptr; }
246  const_iterator end() const { return m_array_ptr + size(); }
247  /// Returns a constant pointer to the first element in the array.
248  const_iterator cbegin() const { return begin(); }
249  /// Returns a constant pointer to the past-the-end element in the array.
250  const_iterator cend() const { return end(); }
251 
252  /**
253  Assigns a value to an arbitrary element, even where n >= size().
254  The array is extended with default values if necessary.
255  @retval true if out-of-memory, false otherwise.
256  */
257  bool assign_at(size_t n, const value_type &val) {
258  if (n < size()) {
259  at(n) = val;
260  return false;
261  }
262  if (reserve(n + 1)) return true;
263  resize(n);
264  return push_back(val);
265  }
266 
267  /**
268  Reserves space for array elements.
269  Copies (or moves, if possible) over existing elements, in case we
270  are re-expanding the array.
271 
272  @param n number of elements.
273  @retval true if out-of-memory, false otherwise.
274  */
275  bool reserve(size_t n) {
276  if (n <= m_capacity) return false;
277 
278  void *mem = my_malloc(m_psi_key, n * element_size(), MYF(MY_WME));
279  if (!mem) return true;
280  Element_type *new_array = static_cast<Element_type *>(mem);
281 
282  // Move all the existing elements into the new array.
283  for (size_t ix = 0; ix < m_size; ++ix) {
284  Element_type *new_p = &new_array[ix];
285  Element_type &old_p = m_array_ptr[ix];
286  ::new (new_p) Element_type(std::move(old_p)); // Move into new location.
288  old_p.~Element_type(); // Destroy the old element.
289  }
290 
292 
293  // Forget the old array;
294  m_array_ptr = new_array;
295  m_capacity = n;
296  return false;
297  }
298 
299  /**
300  Copies an element into the back of the array.
301  Complexity: Constant (amortized time, reallocation may happen).
302  @return true if out-of-memory, false otherwise
303  */
304  bool push_back(const Element_type &element) { return emplace_back(element); }
305 
306  /**
307  Copies (or moves, if possible) an element into the back of the array.
308  Complexity: Constant (amortized time, reallocation may happen).
309  @return true if out-of-memory, false otherwise
310  */
311  bool push_back(Element_type &&element) {
312  return emplace_back(std::move(element));
313  }
314 
315  /**
316  Constructs an element at the back of the array.
317  Complexity: Constant (amortized time, reallocation may happen).
318  @return true if out-of-memory, false otherwise
319  */
320  template <typename... Args>
321  bool emplace_back(Args &&... args) {
322  const size_t expansion_factor = 2;
323  if (m_size == m_capacity && reserve(m_capacity * expansion_factor))
324  return true;
325  Element_type *p = &m_array_ptr[m_size++];
326  ::new (p) Element_type(std::forward<Args>(args)...);
327  return false;
328  }
329 
330  /**
331  Removes the last element in the array, effectively reducing the
332  container size by one. This destroys the removed element.
333  */
334  void pop_back() {
335  assert(!empty());
336  if (!Has_trivial_destructor) back().~Element_type();
337  m_size -= 1;
338  }
339 
340  /**
341  The array is extended by inserting a new element before the element at the
342  specified position.
343 
344  This is generally an inefficient operation, since we need to copy
345  elements to make a new "hole" in the array.
346 
347  We use std::rotate to move objects, hence Element_type must be
348  move-assignable and move-constructible.
349 
350  @return an iterator pointing to the inserted value
351  */
352  iterator insert(const_iterator position, const value_type &val) {
353  return emplace(position, val);
354  }
355 
356  /**
357  The array is extended by inserting a new element before the element at the
358  specified position. The element is moved into the array, if possible.
359 
360  This is generally an inefficient operation, since we need to copy
361  elements to make a new "hole" in the array.
362 
363  We use std::rotate to move objects, hence Element_type must be
364  move-assignable and move-constructible.
365 
366  @return an iterator pointing to the inserted value
367  */
369  return emplace(position, std::move(val));
370  }
371 
372  /**
373  The array is extended by inserting a new element before the element at the
374  specified position. The element is constructed in-place.
375 
376  This is generally an inefficient operation, since we need to copy
377  elements to make a new "hole" in the array.
378 
379  We use std::rotate to move objects, hence Element_type must be
380  move-assignable and move-constructible.
381 
382  @return an iterator pointing to the inserted value
383  */
384  template <typename... Args>
385  iterator emplace(const_iterator position, Args &&... args) {
386  const difference_type n = position - begin();
387  emplace_back(std::forward<Args>(args)...);
388  std::rotate(begin() + n, end() - 1, end());
389  return begin() + n;
390  }
391 
392  /**
393  Similar to std::set<>::insert()
394  Extends the array by inserting a new element, but only if it cannot be found
395  in the array already.
396 
397  Assumes that the array is sorted with std::less<Element_type>
398  Insertion using this function will maintain order.
399 
400  @retval A pair, with its member pair::first set an iterator pointing to
401  either the newly inserted element, or to the equivalent element
402  already in the array. The pair::second element is set to true if
403  the new element was inserted, or false if an equivalent element
404  already existed.
405  */
406  std::pair<iterator, bool> insert_unique(const value_type &val) {
407  std::pair<iterator, iterator> p = std::equal_range(begin(), end(), val);
408  // p.first == p.second means we did not find it.
409  if (p.first == p.second) return std::make_pair(insert(p.first, val), true);
410  return std::make_pair(p.first, false);
411  }
412 
413  /**
414  Similar to std::set<>::erase()
415  Removes a single element from the array by value.
416  The removed element is destroyed.
417  This effectively reduces the container size by one.
418 
419  This is generally an inefficient operation, since we need to copy
420  elements to fill the "hole" in the array.
421 
422  Assumes that the array is sorted with std::less<Element_type>.
423 
424  @retval number of elements removed, 0 or 1.
425  */
427  std::pair<iterator, iterator> p = std::equal_range(begin(), end(), val);
428  if (p.first == p.second) return 0; // Not found
429  erase(p.first);
430  return 1;
431  }
432 
433  /**
434  Similar to std::set<>::count()
435 
436  @note Assumes that array is maintained with insert_unique/erase_unique.
437 
438  @retval 1 if element is found, 0 otherwise.
439  */
440  size_type count_unique(const value_type &val) const {
441  return std::binary_search(begin(), end(), val);
442  }
443 
444  /**
445  Removes a single element from the array.
446  The removed element is destroyed.
447  This effectively reduces the container size by one.
448 
449  This is generally an inefficient operation, since we need to move
450  or copy elements to fill the "hole" in the array.
451 
452  We use std::move to move objects, hence Element_type must be
453  move-assignable.
454  */
456  assert(position != end());
457  return erase(position - begin());
458  }
459 
460  /**
461  Removes a single element from the array.
462  */
463  iterator erase(size_t ix) {
464  assert(ix < size());
465  iterator pos = begin() + ix;
466  if (pos + 1 != end()) std::move(pos + 1, end(), pos);
467  pop_back();
468  return pos;
469  }
470 
471  /**
472  Removes tail elements from the array.
473  The removed elements are destroyed.
474  This effectively reduces the containers size by 'end() - first'.
475  */
478  const difference_type diff = last - first;
479  if (!Has_trivial_destructor) {
480  for (; first != last; ++first) first->~Element_type();
481  }
482  m_size -= diff;
483  }
484 
485  /**
486  Removes a range of elements from the array.
487  The removed elements are destroyed.
488  This effectively reduces the containers size by 'last - first'.
489 
490  This is generally an inefficient operation, since we need to move
491  or copy elements to fill the "hole" in the array.
492 
493  We use std::move to move objects, hence Element_type must be
494  move-assignable.
495  */
497  /*
498  std::move() wants non-const input iterators, otherwise it cannot move and
499  must always copy the elements. Convert first and last from const_iterator
500  to iterator.
501  */
502  iterator start = begin() + (first - cbegin());
503  iterator stop = begin() + (last - cbegin());
504  if (first != last) erase_at_end(std::move(stop, end(), start));
505  return start;
506  }
507 
508  /**
509  Exchanges the content of the container by the content of rhs, which
510  is another vector object of the same type. Sizes may differ.
511 
512  We use std::swap to do the operation.
513  */
514  void swap(Prealloced_array &rhs) {
515  // Just swap pointers if both arrays have done malloc.
516  if (m_array_ptr != cast_rawbuff() &&
517  rhs.m_array_ptr != rhs.cast_rawbuff()) {
518  std::swap(m_size, rhs.m_size);
522  return;
523  }
524  std::swap(*this, rhs);
525  }
526 
527  /**
528  Requests the container to reduce its capacity to fit its size.
529  */
530  void shrink_to_fit() {
531  // Cannot shrink the pre-allocated array.
532  if (m_array_ptr == cast_rawbuff()) return;
533  // No point in swapping.
534  if (size() == capacity()) return;
535  Prealloced_array tmp(m_psi_key, begin(), end());
536  if (size() <= Prealloc) {
537  /*
538  The elements fit in the pre-allocated array. Destruct the
539  heap-allocated array in this, and copy the elements into the
540  pre-allocated array.
541  */
542  this->~Prealloced_array();
543  new (this) Prealloced_array(tmp.m_psi_key, tmp.begin(), tmp.end());
544  } else {
545  // Both this and tmp have a heap-allocated array. Swap pointers.
546  swap(tmp);
547  }
548  }
549 
550  /**
551  Resizes the container so that it contains n elements.
552 
553  If n is smaller than the current container size, the content is
554  reduced to its first n elements, removing those beyond (and
555  destroying them).
556 
557  If n is greater than the current container size, the content is
558  expanded by inserting at the end as many elements as needed to
559  reach a size of n. If val is specified, the new elements are
560  initialized as copies of val, otherwise, they are
561  value-initialized.
562 
563  If n is also greater than the current container capacity, an automatic
564  reallocation of the allocated storage space takes place.
565 
566  Notice that this function changes the actual content of the
567  container by inserting or erasing elements from it.
568  */
569  void resize(size_t n, const Element_type &val = Element_type()) {
570  if (n == m_size) return;
571  if (n > m_size) {
572  if (!reserve(n)) {
573  while (n != m_size) push_back(val);
574  }
575  return;
576  }
577  if (!Has_trivial_destructor) {
578  while (n != m_size) pop_back();
579  }
580  m_size = n;
581  }
582 
583  /**
584  Removes (and destroys) all elements.
585  Does not change capacity.
586  */
587  void clear() {
588  if (!Has_trivial_destructor) {
589  for (Element_type *p = begin(); p != end(); ++p)
590  p->~Element_type(); // Destroy discarded element.
591  }
592  m_size = 0;
593  }
594 
595  private:
596  size_t m_size;
597  size_t m_capacity;
598  // This buffer must be properly aligned.
599  alignas(Element_type) char m_buff[Prealloc * sizeof(Element_type)];
600  Element_type *m_array_ptr;
602 };
603 
604 #endif // PREALLOCED_ARRAY_INCLUDED
A typesafe replacement for DYNAMIC_ARRAY.
Definition: prealloced_array.h:67
bool push_back(const Element_type &element)
Copies an element into the back of the array.
Definition: prealloced_array.h:304
const Element_type & operator[](size_t n) const
Definition: prealloced_array.h:231
iterator erase(const_iterator first, const_iterator last)
Removes a range of elements from the array.
Definition: prealloced_array.h:496
size_type count_unique(const value_type &val) const
Similar to std::set<>::count()
Definition: prealloced_array.h:440
Prealloced_array(PSI_memory_key psi_key, const_iterator first, const_iterator last)
Range constructor.
Definition: prealloced_array.h:158
size_type erase_unique(const value_type &val)
Similar to std::set<>::erase() Removes a single element from the array by value.
Definition: prealloced_array.h:426
bool empty() const
Definition: prealloced_array.h:217
Prealloced_array(std::initializer_list< Element_type > elems)
Definition: prealloced_array.h:168
Element_type * m_array_ptr
Definition: prealloced_array.h:600
const Element_type & at(size_t n) const
Definition: prealloced_array.h:225
Prealloced_array(PSI_memory_key psi_key)
Definition: prealloced_array.h:97
Element_type & at(size_t n)
Definition: prealloced_array.h:220
Element_type value_type
Standard typedefs.
Definition: prealloced_array.h:90
Prealloced_array(const Prealloced_array &that)
An object instance "owns" its array, so we do deep copy here.
Definition: prealloced_array.h:133
iterator erase(size_t ix)
Removes a single element from the array.
Definition: prealloced_array.h:463
bool emplace_back(Args &&... args)
Constructs an element at the back of the array.
Definition: prealloced_array.h:321
char m_buff[Prealloc *sizeof(Element_type)]
Definition: prealloced_array.h:599
Element_type & front()
Definition: prealloced_array.h:236
Element_type & operator[](size_t n)
Definition: prealloced_array.h:230
void clear()
Removes (and destroys) all elements.
Definition: prealloced_array.h:587
bool reserve(size_t n)
Reserves space for array elements.
Definition: prealloced_array.h:275
static constexpr bool Has_trivial_destructor
Is Element_type trivially destructible? If it is, we don't destroy elements when they are removed fro...
Definition: prealloced_array.h:73
size_t m_capacity
Definition: prealloced_array.h:597
Prealloced_array(Prealloced_array &&that)
Definition: prealloced_array.h:143
Prealloced_array & operator=(const Prealloced_array &that)
Copies all the elements from 'that' into this container.
Definition: prealloced_array.h:175
void resize(size_t n, const Element_type &val=Element_type())
Resizes the container so that it contains n elements.
Definition: prealloced_array.h:569
const_iterator cbegin() const
Returns a constant pointer to the first element in the array.
Definition: prealloced_array.h:248
static const size_t initial_capacity
Initial capacity of the array.
Definition: prealloced_array.h:87
void swap(Prealloced_array &rhs)
Exchanges the content of the container by the content of rhs, which is another vector object of the s...
Definition: prealloced_array.h:514
iterator insert(const_iterator position, value_type &&val)
The array is extended by inserting a new element before the element at the specified position.
Definition: prealloced_array.h:368
size_t m_size
Definition: prealloced_array.h:596
bool assign_at(size_t n, const value_type &val)
Assigns a value to an arbitrary element, even where n >= size().
Definition: prealloced_array.h:257
void pop_back()
Removes the last element in the array, effectively reducing the container size by one.
Definition: prealloced_array.h:334
~Prealloced_array()
Runs DTOR on all elements if needed.
Definition: prealloced_array.h:208
Element_type * cast_rawbuff()
Casts the raw buffer to the proper Element_type.
Definition: prealloced_array.h:81
PSI_memory_key m_psi_key
Definition: prealloced_array.h:601
Element_type * iterator
Definition: prealloced_array.h:94
iterator erase(const_iterator position)
Removes a single element from the array.
Definition: prealloced_array.h:455
size_t capacity() const
Definition: prealloced_array.h:215
const Element_type & back() const
Definition: prealloced_array.h:234
const_iterator cend() const
Returns a constant pointer to the past-the-end element in the array.
Definition: prealloced_array.h:250
void shrink_to_fit()
Requests the container to reduce its capacity to fit its size.
Definition: prealloced_array.h:530
iterator emplace(const_iterator position, Args &&... args)
The array is extended by inserting a new element before the element at the specified position.
Definition: prealloced_array.h:385
size_t size() const
Definition: prealloced_array.h:218
ptrdiff_t difference_type
Definition: prealloced_array.h:92
void erase_at_end(const_iterator first)
Removes tail elements from the array.
Definition: prealloced_array.h:476
std::pair< iterator, bool > insert_unique(const value_type &val)
Similar to std::set<>::insert() Extends the array by inserting a new element, but only if it cannot b...
Definition: prealloced_array.h:406
bool push_back(Element_type &&element)
Copies (or moves, if possible) an element into the back of the array.
Definition: prealloced_array.h:311
const Element_type & front() const
Definition: prealloced_array.h:237
const_iterator begin() const
Definition: prealloced_array.h:245
Prealloced_array(PSI_memory_key psi_key, size_t initial_size)
Initializes (parts of) the array with default values.
Definition: prealloced_array.h:109
iterator begin()
begin : Returns a pointer to the first element in the array.
Definition: prealloced_array.h:243
Prealloced_array & operator=(Prealloced_array &&that)
Definition: prealloced_array.h:183
Element_type & back()
Definition: prealloced_array.h:233
iterator end()
Definition: prealloced_array.h:244
iterator insert(const_iterator position, const value_type &val)
The array is extended by inserting a new element before the element at the specified position.
Definition: prealloced_array.h:352
size_t element_size() const
Definition: prealloced_array.h:216
const_iterator end() const
Definition: prealloced_array.h:246
const Element_type * const_iterator
Definition: prealloced_array.h:95
size_t size_type
Definition: prealloced_array.h:91
const char * p
Definition: ctype-mb.cc:1236
char * pos
Definition: do_ctype.cc:76
static Bigint * diff(Bigint *a, Bigint *b, Stack_alloc *alloc)
Definition: dtoa.cc:1082
#define MY_WME
Definition: my_sys.h:122
unsigned int PSI_memory_key
Instrumented memory key.
Definition: psi_memory_bits.h:48
static void start(mysql_harness::PluginFuncEnv *env)
Definition: http_auth_backend_plugin.cc:161
Header for compiler-dependent features.
Some integer typedefs for easier portability.
#define MYF(v)
Definition: my_inttypes.h:96
void my_free(void *ptr)
Frees the memory pointed by the ptr.
Definition: my_memory.cc:80
void * my_malloc(PSI_memory_key key, size_t size, int flags)
Allocates size bytes of memory.
Definition: my_memory.cc:56
Common header for many mysys elements.
const string value("\"Value\"")
Performance schema instrumentation interface.
static void stop(mysql_harness::PluginFuncEnv *)
Definition: rest_mock_server.cc:276
static MEM_ROOT mem
Definition: sql_servers.cc:98
static void swap(String &a, String &b) noexcept
Definition: sql_string.h:610
#define PSI_NOT_INSTRUMENTED
Definition: validate_password_imp.cc:39
int n
Definition: xcom_base.cc:445